那麼爲什麼這不起作用呢?不知道爲什麼這是不可能的 - 我只是想在2d數組中存儲一個2號數組。我知道這將相當於設置存儲[0] [0] =數組[0]和存儲[0] [1] =數組[1],但只是想知道爲什麼這是不正確的。將數組存儲在2d數組中Java
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是一個2-dim數組'storage [i]'是一個1-dim數組,就像你的'array'變量。 –