为什么这不起作用?不太确定为什么这是不可能的 - 我只是想将大小为2的数组存储在二维数组中。
我知道这相当于设置 storage[0][0] = array[0] 和 storage[0][1] = array[1],但只是想知道为什么这是不正确的。
public class Test {
public static void main(String[] args) {
boolean[][] storage = new boolean[10][2];
boolean[] array = new boolean[2];
array[0] = true;
array[1] = false;
storage[0][] = array; //Why can't I do this?
}
}
提前感谢您的帮助。
storage[0]=array;
,因为如果 storage 是一个二维数组,那么storage[i]
就是一个一维数组,与你的array
变量类似。 - Alexis C.