我正在尝试从ArrayList中删除int [].由于我的代码,我只有值,所以我创建数组,然后调用remove();
int[] pos = new int[]{0,1};
positionList.remove(pos);
Run Code Online (Sandbox Code Playgroud)
positionList是相应的ArrayList
这实际上不起作用.还有另一种可能性,比如遍历列表
for (int[] pos : positionList) {
if (posX == pos[0] && posY == pos[1]) {
positionList.remove(pos);
break;
}
}
Run Code Online (Sandbox Code Playgroud)