posted 22 years ago
To answer your first question:
When you execute this statement:
int myInt [][] = new int [3][];
You are creating a two dimensional array with the size of one dimension as 3 that contains null refrences to the other dimension, i.e. even though you are specifying one dimension as 3, this dimension of the array is not initialized with the default primitve values (0 in this case of integer) - it is initialized with null references to the second dimension.
Try out the following code to understand what I am trying to say:
So, I would say there are 3 null references in the array in your example and 5 null references in my example. I do not know if you can classify them as array elements. The array certainly does not have default integer primitive values, i.e. zeroes.
Brian
PS - I just came up with this sentence:
"In a partially constructed primitive multi dimensional array, the dimension that is fully constructed contains null references to the dimension that is not fully constructed. It does not contain default primitive values"
Feel free to correct this statement, keeping in mind my post.
[ February 22, 2002: Message edited by: Brian Lugo ]
[ February 22, 2002: Message edited by: Brian Lugo ]