Multidimensional Arrays

You can access the individual 1D arrays in a multi-dimensional array using the .length property of arrays.

arrayName.length is the number of rows

arrayName[rowNumber].length is the number of columns in the given row

To access each individual element in a multidemensional array, you need to use nested for loops.

In a basic formula, you would do so like this:

for(int row = 0; row < arrayName.length; row++) {

for(int column = 0; column < arrayName[row].length; column++) {

}

}

 

Leave a Reply