when traversing the set, use iterator to modify the set to avoid the ConcurrentModificationException.

for...loop cannot modify.

Iterator<String> iterator = list.iterator();
for (iterator.hasNext();) {
    String s =  iterator.next();
    if (s.length() % 2 == 0) {
        iterator.remove();
    }       
}

results matching ""

    No results matching ""