Embed presentation
Download to read offline


![11
Declare a two-dimensional array:
int[][] anArray = new int[5][5];
Declaring a Two-Dimensional Array](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-3-320.jpg)
![11
Iterating a Two-Dimensional Array
Use a nested for loop:
Outer loop iterates the row
Inner loop iterates the column.
for ( int i=0; i<5; i++ )
{
for ( int j=0; j<5; j++ )
{
anArray[i][j] = i+j;
}
}](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-4-320.jpg)
![11
Multidimensional Arrays
Arrays can have more than two
dimensions.
Multidimensional arrays are not
commonly used as they quickly become
difficult to manage.
Declare multidimensional array:
int[][][] anArray = new
int[5][5][5];](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-5-320.jpg)



A two-dimensional array can be thought of as a series of one-dimensional arrays stacked on top of each other. It has rows and columns. To declare a two-dimensional array, use int[][] and specify the number of rows and columns by initializing it with new int[rows][columns]. A two-dimensional array can be iterated through using nested for loops, with the outer loop iterating through rows and the inner loop iterating through columns.


![11
Declare a two-dimensional array:
int[][] anArray = new int[5][5];
Declaring a Two-Dimensional Array](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-3-320.jpg)
![11
Iterating a Two-Dimensional Array
Use a nested for loop:
Outer loop iterates the row
Inner loop iterates the column.
for ( int i=0; i<5; i++ )
{
for ( int j=0; j<5; j++ )
{
anArray[i][j] = i+j;
}
}](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-4-320.jpg)
![11
Multidimensional Arrays
Arrays can have more than two
dimensions.
Multidimensional arrays are not
commonly used as they quickly become
difficult to manage.
Declare multidimensional array:
int[][][] anArray = new
int[5][5][5];](https://image.slidesharecdn.com/chapter11-140413041724-phpapp02/85/Chapter-11-5-320.jpg)

