最佳答案
在循环访问列表时,我希望根据条件删除列表中的某个项。请参阅下面的代码。
这给了我一个 ConcurrentModification
异常。
for (Object a : list) {
if (a.getXXX().equalsIgnoreCase("AAA")) {
logger.info("this is AAA........should be removed from the list ");
list.remove(a);
}
}
这怎么可能呢?