所以我想從我已經放入正常數組的ArrayList中移除Integer。從ArrayList中放入數組並將其刪除for循環
我現在所擁有的是:
int[] playersArray = null;
ArrayList<Integer> spelers = new ArrayList<Integer>();
的table.lengthü下這裏看到的是表有量,表[J]。長度爲玩家每個表都可以得到數額。它的效果很好,但是它從PlayerList中移除了錯誤的Integer,它將刪除下一個,而不是放入playersArray中的那個。
for(int j = 0; j < table.length; j++){
playersArray = new int[table[j].length];
for(int i = 0; i < table[j].length; i++){
playersArray[i] = playersList.get(i);
playersList.remove(i);
}
table[j] = playersArray;
System.out.println("tafel: " + (j+1) + " " + Arrays.toString(tafel[j]));
}
您是否嘗試過閱讀「ArrayList#remove」的作用以及列表內容的行爲方式?只需使用[這裏]的方法之一(http://stackoverflow.com/questions/718554/how-to-convert-an-arraylist-containing-integers-to-primitive-int-array)並清除'playersList'之後... – Tom
也顯示'table'的聲明。 –