Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multidimensional arrays

 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that is correct. The size of an int[][] doesn't have to be a square. Example

 
shuba gopal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Wouter
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why a lot of people don't like the term "multidimensional arrays". They are arrays of arrays (of arrays etc).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic