• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ask About Array Multidimensional

 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hay all master, i am confused about array mutidimensional.
I wonder, how many object can construct for this array?



Thank you
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You first. How many do you think?
 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure, honestly i don't know.
Once i think 3*9 = 12 is number of object, but i am wrong. It's number of element.

In my book that i read, it has 4(1+3) object.
I confused . Please explain to me.

Thank you for your response.

Darryl Burke wrote:You first. How many do you think?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java doesn't really have multi-dimensional arrays. Instead, what it has is arrays-of-arrays. Given that, does that number make sense now?
 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Java doesn't really have multi-dimensional arrays. Instead, what it has is arrays-of-arrays. Given that, does that number make sense now?


Yes, of course Java builds multi-dimensional arrays from many one-dimensional arrays.
Just now, i get some reference , it says :

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.
This case for array :


It is correct?

I am sorry for my bad english.
Thank you.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49841
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fandy Akhmad wrote: . . .
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.
. . .
It is correct?
. . . .
No. 1 + 10 = 6???

That statement is incorrect in two respects.
  • 1: It does not only allocate space, but also creates the objects.
  • 2: When I was a little boy at school, 1 + 10 always made 11
  • Please tell us where you found that statement.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic