This seems an interesting question and I just want to make sure I understand the concepts.
At the end of this line
What happens exactly?List list = new ArrayList();
Does it allocate space for the ArrayList since we have the "new" keyword? Or not yet?
Are the array elements initialized to null? I assume not as we don't know how many they are...
Please explain a little bit what happens here. I assume this is an empty array with a potential that each of its elements may point to what we will add inside.
I thought the code compiles as the elements are all null and then it doesn't matter in which order they're set.
What if it would have been List list = new ArrayList(3)?
Would the code work then?
Thanks