class Demo{
public static void main(String[] args) {
int [][]arr={{22,66,44},{77,33,88},{25,45,65},{ 11,66,99}}; //定义一个二维数组
int sum =0;
for (int i=0;i<arr.length ;i++ ) { //遍历一维数组
for (int j=0; j <arr[i].length; j++) { //遍历二维数组
sum+=arr[i][j]; //累加就和
}
}
System.out.println("sum="+sum);
}
}
|