... array[row][column]);
24            }
25
26            System.out.println();
27         }
28      }
29   }
Values in array1 by row are
1   2   3
4   5   6

Values in array2 by row are
1   2
3
4   5   6

Initializing two-dimensional arrays.

Lines 11 and 14 call method outputArray (lines 18–28) to output the elements of array1 and array2, respectively. Method outputArray’s parameter—int[][] array—indicates that the method receives a two-dimensional array. The nested for statement (lines 20–27) outputs the rows of a two-dimensional array. In the loop-continuation condition of the outer for statement, the expression array.length determines the number of rows in the array. In the inner for statement, the expression array[row].length determines the number of columns in the current row of the array. The inner for ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.