wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Multidimensional arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multidimensional arrays" Watch "Multidimensional arrays" New topic

Multidimensional arrays

shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
In K & B SCJP 6, solution I came across a statement "Multidimensional arrays' dimension can be inconsistent". Does it mean that the individual arrays of an array of arrays can have different dimensions? The following is the program:

Does the statement refer to the fact that dd has arrays with 3 and 4 elements?

The solution is 4 (dd[1][2])

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Yes that is correct. The size of an int[][] doesn't have to be a square. Example

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
shuba gopal
Ranch Hand

Joined: May 12, 2011
Posts: 76
Thanks Wouter
Rob Spoor

Joined: Oct 27, 2005
Posts: 19654

That's why a lot of people don't like the term "multidimensional arrays". They are arrays of arrays (of arrays etc).

How To Ask Questions How To Answer Questions
Don't get me started about those stupid light bulbs.
subject: Multidimensional arrays
Similar Threads
Multidimensional arrays
Doubt related to post-increment operators
Constructing multidimensional arrays
multidimensional array
Cannot understand the program