有三维数组
public class test {
static int n = 0;
public static void main (String[] args){
int[][][] a = {{{1},{2,2}},{{3,3}}}; //声明并赋值
int b[][][] ; //声明
b = new int [2][2][2];
for(int i = 0;i<b.length;i++){ //循环中赋值
for(int j = 0;j<b[i].length;j++){
for(int k = 0;k<b[i][j].length;k++){
b[i][j][k] = n++;
System.out.print(b[i][j][k]+" ");
}
}
}
}
} |