Java非均匀多维数组
我是根据这段代码来的,我不确定到底发生了什么。内容如下:
int twod [] [] = new int[4][];// i know the first one is row
twod [0] = new int[1];//
twod [1] = new int[2];// What are these?
twod [2] = new int[3];//
twod [3] = new int[4];//
最后4行在做什么
# 1 楼答案
上面的代码无法编译。但我有一种强烈的感觉,OP的意思是:
这将创建以下形状的数组(向上->;向下=第一维,向左->;向右=第二维):
更具体地说,当我们查询数组的长度时,我们会得到以下结果:
# 2 楼答案
你发布的内容没有为我编译。我想这就是你想要的锯齿阵列
结果(在调试中):