Q: Most efficient way to remove object from inside of an iterating ArrayList I'm trying to remove an object from an iterating ArrayList but cannot do so from inside of the loop, here is what I have at the moment
        for(Pearl pearl : this.pearls){
            pearl.onDraw(canvas);

            if(fish.isCollide(pearl)){
                this.pearls.remove(pearl);
            }
        }

The above code does not work if the ArrayList is larger than 1. 
I was thinking of changing the code to something such as the following but would prefer to know if there is a simpler way.
       List<Pearl> pearls_delete = new ArrayList<Pearl>();


       for(Pearl pearl : this.pearls){
            pearl.onDraw(canvas);

            if(fish.isCollide(pearl)){
                pearls_delete.add(pearl);
            }
        }

        this.pearls.removeAll(pearls_delete);


A: Use an Iterator
Iterator<Pearl> iter = this.pearls.iterator();
while ( iter.hasNext() ) {
   Pearl pearl = iter.next();
   // logic
   iter.remove();
} 

or simply
for (Iterator<Pearl> iter = pearls.iterator(); iter.hasNext();) {
   Pearl pearl = iter.next();
   // logic
   iter.remove();
} 

