File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 20274

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
I agree. Here's the link:
subject: Multidimensional arrays
jQuery in Action, 3rd edition