File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 563
Two nested for loops that iterate from 0 to < the array.length should work nicely.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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: 55

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


Twitter: @realEdwinTorres
Blog: java Friendly
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
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: 8427
    
  23

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multidimensional array