JAVA-二维数组遍历
改进代码
改进代码
最终遍历代码
package com.itheima;
public class shuzu06 {
public static void main(String[] args) {
int[][] arr={{1,2,3},{4,5,6},{7,8,9}};
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}
}
执行结果
1 2 3
4 5 6
7 8 9
Process finished with exit code 0