/** * Created by xabcd on 2019/2/14. */ public class java_3arrays { public static void main(String args[]) { int i, j, k, sum = 0; int A[][][] = {{{5, 1}, {6, 7}}, {{9, 4}, {8, 3}}}; for (i = 0; i < A.length; i++) for (j = 0; j < A[i].length; j++) for (k = 0; k < A.length; k++) { System.out.print("A[" + i + "][" + j + "][" + k + "] ="); System.out.println(A[i][j][k]); sum += A[i][j][k]; } System.out.println(sum); } } 结果: A[0][0][0] =5 A[0][0][1] =1 A[0][1][0] =6 A[0][1][1] =7 A[1][0][0] =9 A[1][0][1] =4 A[1][1][0] =8 A[1][1][1] =3 43