If I have a class say A, and I declare an array of 10 elements of this class as,
A [] arr=new A[10];
Then 10 new objects of A are created and stored in the array.
However, i'd like to be able to do something on the lines of A arr[10]; , where the array just holds references to null objects.
The reason I need this is because I only need the array to hold instances I fill in later in the code. So the objects the above statement creates are lost anyway and as I understand object creation is expensive.
So, is there any way to just have an array of references that I can point to the objects I desire later? Or is this not possible and I should resort to using an ArrayList?