23、多维数组

多维数组

image-20210625211551129

image-20210625212122952

public class ArrayDemo08 {
    public static void main(String[] args) {
        //[4][2]
        /*
            1,2     array[0]
            3,4     array[1]
            5,6     array[2]
            7,8     array[3]
         */

        int[][] arrays = {{1,2},{3,4},{5,6},{7,8}};
        for ( int i = 0; i < arrays.length; i++ ) {
            for ( int j = 0; j < arrays[i].length; j++ ) {
                System.out.print(arrays[i][j]);
            }
            System.out.println();
        }
    }
}

image-20210625214441523

public class ArrayDemo09 {
    public static void main(String[] args) {
        //[2][5]    两行五列
        /*
            1,2,3,4,5   arrays[0]
            6,7,8,9,10  arrays[1]
         */

        int[][] arrays = {{1,2,3,4,5},{6,7,8,9,10}};

        for ( int i = 0; i < arrays.length; i++ ) {
            for ( int j = 0; j < arrays[i].length; j++ ) {
                System.out.print(arrays[i][j]);
            }
            System.out.println();
        }
    }
}

image-20210625215317438

posted @ 2021-06-27 17:57  多瑞C  阅读(32)  评论(0)    收藏  举报