This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Multidimensional array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multidimensional array" Watch "Multidimensional array" New topic
Author

Multidimensional array

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583



Tell the difficulties that i am difficult.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Two nested for loops that iterate from 0 to < the array.length should work nicely.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37923
    
  22
There is no such thing as a 2D array. You do realise you are going to hit some nulls when you iterate that array?
Edwin Torres
Ranch Hand

Joined: Mar 19, 2011
Posts: 37
Like they said, initialize the third row (to avoid the null) and use a nested loop:


Follow me: @CompGuyProbs
Read me: Freehold Computers Examiner
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Working with arrays of arrays can be confusing, requiring extrapolating simple ideas you probably already know into more complex ones in ways you might not think of or realize are possible. For that reason, I put together a short runnable example that should answer most of your questions. Please ask if you have more.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7493
    
  18

Edwin Torres wrote:Like they said, initialize the third row (to avoid the null) and use a nested loop:

Or indeed:
Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583

Thanks everyone
 
 
subject: Multidimensional array
 
Similar Threads
Multi dimensional array
SCJP : query regarding increment/decrement operator.
question related to ragged array
array out of bounds
Sudoku Solver