如何將數組存儲在單個數組中? 例如我有四個不同的數組,我想將它存儲在單個數組中int storeAllArray []
,當我打電話給storeAllArray [1],我會得到這個輸出[11,65,4,3,2,9,7]
而不是單個元素?如何將數組存儲在單個數組中
int array1 [] = {1,2,3,4,5,100,200,400};
int array2 [] = {2,6,5,7,2,5,10};
int array3 [] = {11,65,4,3,2,9,7};
int array4 [] = {111,33,22,55,77};
int storeAllArray [] = {array1,array2,array3,array2}
//我希望所有的陣列中的存儲陣列上
for (int i=0; i<storeAllArray; i++){
System.out.println(storeAllArray.get[0]); // e.g. will produce --> 1,2,3,4,5,100,200,400 , how can I do this?
}
編輯: 我怎樣才能得到輸出這樣?
System.out.println(storeAllArray [0]) --> [1,2,3,4,5,100,200,400];
System.out.println(storeAllArray [1]) --> [2,6,5,7,2,5,10];
System.out.println(storeAllArray [2]) --> [11,65,4,3,2,9,7];
System.out.println(storeAllArray [2]) --> [111,33,22,55,77];
的可能重複的[如何弄平2D陣列到一維數組?](http://stackoverflow.com/questions/2569279/how-to-flatten-2d-array-to-1d-array) – givanse 2013-12-19 16:23:47
@givanse不得不在這裏不同意。您所關聯的問題是關於如何將二維數組轉換爲一維數組,當這個問題真的在詢問有關製作二維數組的問題時。 – 2013-12-19 16:48:12