1 2 int arr[][]=new int[][]{{12,8,45},{11,34,23,76}}; 3 4 int sum = 0; 5 6 System.out.println("数组元素是:"); 7 8 for (int c[]:arr) 9 { 10 for (int b:c) 11 { 12 System.out.print(b+" "); 13 14 sum+=b; 15 } 16 System.out.println(); 17 } 18 19 System.out.println("数组和为:"+sum); 20 21 } 22 23 }
数组元素是:
12 8 45
11 34 23 76
数组和为:209