for (int[ ] row : matrix) { for (int number : row) System.out.print(number + " "); System.out.println(); } } } Does the nested for..each loop, in figure 15.9, make sense? The outer loop - in a concise, Java statement - says the following in English ... For each array element row in matrix, which is an int array, do the following ... Well, inside the outer for..each loop is an inner for..each loop, which continues with its own Java logic and once again we can say in English ... For each element number in row, which is an int, display the number. for..each Loop Structure Limitations The for..each loop structure is read only for any type of data structure. This is true for the one-dimensional array as well as the two-dimensional array. Furthermore, the for..each loop will access every element of the array and cannot be limited to smaller section. 15.4 2D Arrays and the length
for (int[ ] row : matrix) { for (int number : row) System.out.print(number + " "); System.out.println(); } } } Does the nested for..each loop, in figure 15.9, make sense? The outer loop - in a concise, Java statement - says the following in English ... For each array element row in matrix, which is an int array, do the following ... Well, inside the outer for..each loop is an inner for..each loop, which continues with its own Java logic and once again we can say in English ... For each element number in row, which is an int, display the number. for..each Loop Structure Limitations The for..each loop structure is read only for any type of data structure. This is true for the one-dimensional array as well as the two-dimensional array. Furthermore, the for..each loop will access every element of the array and cannot be limited to smaller section. 15.4 2D Arrays and the length
Text15-Two-DimensionalArray.docx