public class Break { public static void main(String[] args) { int[][] arr = new int[3][]; arr[0] = new int[]{11, 12}; arr[1] = new int[]{1, 2, 3}; arr[2] = new int[]{9, 1, 1, 1, 12, 1}; int sum = 0; for (int i = 0; i < arr.length; i++) { //行数 int groupSum = 0; for (int j = 0; j < arr[i].length; j++) { groupSum += arr[i][j]; } sum += groupSum; System.out.println("第"+(i+1)+"行的和为:"+groupSum); } System.out.println("数组总和为:"+sum); } }