Two Laptop Bag*
The moose likes Beginning Java and the fly likes Ask About Array Multidimensional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Ask About Array Multidimensional" Watch "Ask About Array Multidimensional" New topic
Author

Ask About Array Multidimensional

Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

Hay all master, i am confused about array mutidimensional.
I wonder, how many object can construct for this array?



Thank you
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

You first. How many do you think?


luck, db
There are no new questions, but there may be new answers.
Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

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

Joined: Apr 06, 2010
Posts: 4246
    
    7

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

Joined: Nov 26, 2011
Posts: 32

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

Joined: Oct 13, 2005
Posts: 36599
    
  16
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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Ask About Array Multidimensional
     
    Similar Threads
    doubt pg 340 of k&b
    array sort
    question related to ragged array
    array
    Array dimension missing