为了避免ConcurrentModificationException,我采取以下措施:
List<String> tobeRemoved = new ArrayList<String>();
for (Object propertyKey : suppliedContent.keySet()) {
key = (String) propertyKey;
if (EqualityUtils.isMatching(rgx, key)) {
tobeRemoved.add(key);
}
}
for (String o : tobeRemoved) {
suppliedContent.remove(o);
}
有没有更清洁的方法?