我有一个10个正非零整数的ArrayList.
0: 1103
1: 711
2: 199
3: 1527
4: 1745
5: 1530
6: 984
7: 798
8: 927
9: 1986
Run Code Online (Sandbox Code Playgroud)
当我跑这个
for(int i = 0; i < l1.length; i++){
int temp = l1.retrieveAt(i);
int temp2 = temp % 2;
if(temp2 == 1){
l1.removeAt(i);
}
}
Run Code Online (Sandbox Code Playgroud)
列表更改为
0: 711
1: 1527
2: 1530
3: 984
4: 798
5: 1986
Run Code Online (Sandbox Code Playgroud)
L1是的目的UnorderedArrayList延伸ArrayListClass它实现ArrayListADT(点击引擎收录)
retrieveAt(index)并且removeAt(index)是ArrayListClass的方法.