I'm trying to remove an item of type SubClass from an ArrayList using a foreach, and removing it right when it finds it.
The code:
for (SuperClass item : list)
{
if (item instanceof SubClass)
{
list.remove(item);
}
}
I don't really know how the Iterator works in this case, but what I'm asking is: is this safe? Or should it throw an out of bounds exception?
Any help is appreciated!