aspose file tools
The moose likes Java in General and the fly likes Iterating a Two Dimensional Array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Iterating a Two Dimensional Array" Watch "Iterating a Two Dimensional Array" New topic
Author

Iterating a Two Dimensional Array

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
This question has probably been asked many times but here goes.

I have a two dimensional array and I cannot figure out how to interate through it that makes any sense.

I have a for loop but how do I know how many elements will be in the array for my second arry parameter

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You need a nested loop. This can be done using the traditional way, or with the for-each loop:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1254
Rob Spoor wrote:You need a nested loop. This can be done using the traditional way, or with the for-each loop:


Thanks.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9944
    
    6

point to remember - you don't have a two-dimensional array. You have a one dimensional array that hold items. those item happen to be...arrays.

Each element in your first array can be a different size - what is called a 'ragged array'.


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterating a Two Dimensional Array
 
Similar Threads
How to implement a sparsely populated two-dimensional array.
Array dimension - pl explain
Array conversion Question from Dan's test
Can this Java code convert to Javascript code
Stuck on Homework