Take a situation where you have, let's say, an ArrayList that supports a remove function -- it deletes the entry and shifts everything to the right of it left one.
If I want to remove things from the list under a certain condition, I might do this:
for (int i = 0; i < list.size(); i++) {
if (condition) {
list.remove(i);
i--;
}
}
but this is ugly and feels hackish. You could do the same with an Iterator, but you shouldn't be altering lists while using iterators.
So what's the non-ugly solution?