经过前面对一维数组和二维数组的学习,我们充分的掌握了数组的定义和使用,接下来我们该学习的是:多维数组。
比较简单的方法,想要提高数组的维数只要在声明的时候在索引多加一个中括号即可。
比如:我们要声明三维数组那么声明的时候要这样写:int score[][][]=……
看一下简单的三维数组静态的初始化。
public class kyy{
public static void main(String args[]){
int score[][][]= {
{
{5,1} ,{6,7}
},
{
{9,4},{8,3}
}
} ;
for (int i=0;i<score.length ;i++ )
{
for (int j=0;j<score[i].length ;j++ )
{
for (int k=0;k<score[i][j].length ;k++ )
{
System.out.println(score[i][j][k]+"\t");
}
}
}
}
}
转载于:https://blog.51cto.com/crhack/1211805