I'm finding conflicting advice over the best way to avoid a ConcurrentModificationException
while doing this:
List<Apple> Apples = appleCart.getApples();
for (Apple apple : Apples)
{
delete(apple);
}
I'm leaning towards using an Iterator
in place of a List
and calling its remove
method.
Does that make the most sense here?