-->
当前位置:首页 > 题库

单选题:Given list an object of ArrayList, which code below for //todo d

Luz5年前 (2021-05-10)题库1276
Given list an object of ArrayList, which code below for //todo delete can remove an element in the list correctly and safely? @[D](2)
```Java
Iterator it = list.iterator();
int index = 0;
while (it.hasNext()){
Object obj = it.next();
if (needDelete(obj)) { // returns Boolean for removing or not
//todo delete
}
index ++;
}
```
A. list.remove(obj);
B. list.remove(index);
C. list.remove(it.next());
D. it.remove();





A.list.remove(obj);
B.list.remove(index);
C.list.remove(it.next());
D.it.remove();


答案:D