在循环列表时,我想根据条件删除列表中的项目。请参阅下面的代码。
这给了我一个ConcurrentModification
例外。
for (Object a : list) {
if (a.getXXX().equalsIgnoreCase("AAA")) {
logger.info("this is AAA........should be removed from the list ");
list.remove(a);
}
}
如何才能做到这一点?
相似问题