-2
我需要一個包含可變數目數組的數組ListList。帶有可變數目數組的ArrayList
ArrayList <int[]> aa = new ArrayList<int[]>();
int b = 1;
int array [] = new int [5];
while (b == 1){
for (int i=0; i < array.length; i++){
array [i] = in.nextInt();
}
aa.add(array);
System.out.println("If you want to insert another array, press 1");
b = in.nextInt();
}
邏輯驗證碼不起作用,因爲數組被覆蓋每次和結束時的輸出始終是相同的......我怎麼能解決我的問題? .. :)
把循環中的數組的聲明,你會很好去。 –
你爲什麼要硬編碼數組長度? – efekctive
@efekctive。只要價值得到正確使用,爲什麼它很重要? –