三维数组

package com.company;

public class Main {

    public static void main(String[] args) {
    // write your code here
        int a[][][]=new int[2][3][4];
        for (int i=0;i<a.length;i++){
            for (int j=0;j<a[i].length;j++){
                for (int k=0;k<a[i][j].length;k++){
                    a[i][j][k]=i+j+k;
                }
            }
        }
        for(int i=0;i<a.length;i++){
            System.out.println("-----第"+i+"层-----");
            for (int j=0;j<a[i].length;j++){
                for (int k=0;k<a[i][j].length;k++){
                    System.out.print(a[i][j][k]+" ");
                }
                System.out.println(" ");
            }
        }
    }
}

 

posted @ 2018-10-29 22:06  逐梦武威  阅读(442)  评论(0编辑  收藏  举报