package day02;
public class ForTwoArray {
public static void main(String[] args) {
//二维数组循环遍历
int[][] arr = {{1, 2, 3}, {4, 5}, {6, 7, 8, 9}};
ForArray(arr);
}
public static void ForArray(int[][] arr) {
int sum=0;
for (int i = 0; i < arr.length; i++) {//arr.length是统计二维数组中有几个一维数组
for (int j = 0; j < arr[i].length; j++) {//arr[i].length是统计每个一维数组的长度
sum=sum+arr[i][j];
System.out.print(arr[i][j]);
}
}
System.out.println("二维数组之和为:"+sum);
}
}