I have a doubt in number of objects created in total in case of multidimensional array.
This is the example below i picked from a java tutorial website.
It says 6 objects created in this example , i dint understand how?
Someone please explain to me.
It should be 12 as fas ar i know.I refered to many other websites too.
no of objects=now of rows+1 object to hold rows-reference/count+1 2Dobject array reference
int a2 = new int;
This allocates an int array with 10 rows and 5 columns. As with all objects, the values are initialized to zero (unlike local variables which are uninitialized).
This actually allocates 6 objects: a one-dimensional array of 5 elements for each of the rows, and a one-dimensional array of ten elements, with each element pointing to the appropriate row array.