We need to know that there is no concept of multi-dimensional arrays in Java, because from the perspective of the underlying operating mechanism of arrays, Java does not have multi-dimensional arrays, but Java provides syntax to support multi-dimensional arrays, which can realize the functions of multi-dimensional arrays, for example, three-dimensional array int arr [][][], four-dimensional array int arr[][][][], and so on.
Java uses "array of arrays" to declare multi-dimensional arrays . A two-dimensional array is composed of several one-dimensional arrays, then a three-dimensional array is composed of several two-dimensional arrays. In other words, suppose a three-dimensional array is regarded as A one-dimensional array, then each element of this three-dimensional array is a two-dimensional array, and by analogy, we can get any multi-dimensional array.
For example:
publicclassMain{publicstaticvoidmain(String[]args){String[][][]name={{{small d, small o, small t},{small c, small p}},{{Xiao Zhao, Xiao Qian},{ Xiao Sun, Xiao Li, Xiao Zhou}},{{Wu Yue, Zheng Yang},{Wang Xing, Feng Yun, Chen Xue}}};for(inti=0;i<name.length;i++){for( intj=0;j<name[i].length;j++){for(intk=0;k<name[i][j].length;k++){System.out.println(name[+i+][+ j+][+k+]=+name[i][j][k]);}}}}}
The running results are as follows:
name[0][0][0]=small dname[0][0][1]=small oname[0][0][2]=small tname[0][1][0]=small cname[ 0][1][1]=小pname[1][0][0]=Xiao Zhao name[1][0][1]=Xiao Qian name[1][1][0]=Xiao Sun name[ 1][1][1]=Xiao Li name[1][1][2]=Xiao Zhou name[2][0][0]=Wu Yue name[2][0][1]=Zheng Yang name[2][1][0]=王星 name[2][1][1]=Feng Yun name[2][1][2]=Chen Xue