gauravkv gupta wrote:
Please explain the "cond". What is meant by this?
Assume it as a function which return false whenever there is a need to remove a specific element of a Collection otherwise true.
The following method shows you how to use an Iterator to filter an arbitrary Collection — that is, traverse the collection removing specific elements.
static void filter(Collection<?> c) {
for (Iterator<?> it = c.iterator(); it.hasNext(); )
if (!cond(it.next()))
it.remove();
}