JAVA二维数组动态赋值

日常记录二维数据如何动态赋值

    private int[] regionList;
    private int[][] moduleList;
    int m = 0;
    int s = 0;

    public void test() {

        //初始化数据
        regionList = new int[6];
        //指定二维数组中的一维长度
        moduleList = new int[6][];

        //循环获取一维数据和二维数据
        for (int i = 0; i < 6; i++) {

            regionList[i] = m;
            //动态指定二维数组中的二维长度 每段长度不同
            moduleList[i] = new int[i];

            for (int y = 0; y < 9; y++) {
                moduleList[i][y] = s;
            }

        }

    }

你可能感兴趣的:(基础,java)