Collection, remove elements with iteration
java.util.collection
The following code removes elements from a Collection with use of an iteration:
Collection<MyElement> elements = ... Iterator<MyElement> iter = elements.iterator(); while (iter.hasNext()) { MyElement element = iter.next(); if (isElementToRemove(element)) { // isElementToRemove must be implemented of course ;-) iter.remove(); } }