I think only one object will be created only the dots3 reference variable will be provided enough space to hold reference of the 3 individual arrays of size 4 which are not created yet. [ June 21, 2007: Message edited by: raj malhotra ]
Originally posted by Manfred Klug: Not correct. Remember, on the heap are all arrays one dimensional.
I haven't mentioned anything about the dimensions while saying about the object counts. I just said that, "there is only one object created"!..
I do agree with you that the array itself is just an object and nowhere it holds the dimensions for object!! But i have not mentioned that a 2D object is created.
Originally posted by Manfred Klug: And those two statements give you the hint how multidimensional arrays are organized.
What exactly you are trying to say? Can you please elaborate a bit more on this?
Originally posted by Raj malhotra: I think only one object will be created only the dots3 reference variable will be provided enough space to hold reference of the 3 individual arrays of size 4 which are not created yet.
Yes, thats perfectly correct.
Originally posted by Manfred Klug: which of the two definitions do you refer to?
Manfred, Raj's statements seems to be referring to the second one which holds 3*4 dimension.
In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays. This is unlike arrays in C or Fortran.
As consequence, the statement creates four objects.
Hi, I am still not very clear.Let me put it again what I understand: If we write int[][] array = new int[3][]; Then 1 object is created. And if I write int[][] array = new int[3][4]; Then 4 objects are created. Am I right?
int[][] int2DArray = new int[2][2]; //here only one object!
But i was intended to say only one object for the 2D array object "int2DArray". I should have made a note in the comment!
During the second statement of OP, it creates 4 objects. You are right. This holds good when you fill both the dimensions for the 2D Array (or all n dimensions for a nD Array).
Thats fine. I had a small confusion and that was a mistake. I had told in one of the previous replies.
During the second statement of OP, it creates 4 objects. You are right. This holds good when you fill both the dimensions for the 2D Array (or all n dimensions for a nD Array).
I dont get your statement below..
Originally posted by Sergio: [Edit] Sorry, I did not see your previous answer.
Originally posted by Raghavan Muthu: Can you clarify?
Don't worry. I was just refering to your post just above mine. (When I began to answer it wasn't there, so I apologized for repeating what you had just said.) [ June 21, 2007: Message edited by: Sergio Tridente ]