Package com.chongrui.test;
/*
* Initialization and traversal of three-dimensional arrays
* */
public class Test {
public static void Main (string[] args) {
int A[][][]=new int[][][]{
{{1,2,3},{4,5,6}},
{{8,9,10},{11,12,13}},
{{14,15,16},{17,18,19,20}},
};
for (int i=0;i<a.length;i++) {
System.out.println ("the" + (i+1) + "Elements of a three-dimensional array is a" +a[0].length+ "dimension array, as follows:");
for (int j=0;j<a[i].length;j++) {//iterate through each element in the array,
for (int k=0;k<a[0][0].length;k++) {
System.out.print (a[i][j][k]+ "\ t");//The output of each element in the array
}
System.out.println ("");
}
}
}
}
The 1th element of a three-dimensional array is a 2-dimensional array with the following contents:
123
55W
The 2nd element of a three-dimensional array is a 2-dimensional array with the following contents:
8910
111213
The 3rd element of a three-dimensional array is a 2-dimensional array with the following contents:
141516
171819
* Initialization of three-dimensional arrays and traversal of three for loops