I had some trouble using a for each loop for an List at my android project. The error is made by an iterator (or I should better say "the error is made by me - not knowing how to use the iterator"^^). The List is looped through in order to draw bullet objects on a canvas. When one of the bullets leaves the screen I delete this object.
Using a "normal" for-loop solved the error:
for (int ii = 0; ii < bulletList_P1.size(); ii++)
bulletList_P1.get(ii).draw(canvas);
this implementation brings errors:
for (Bullet bullet : bulletList_P1)
bullet.draw(canvas);
I found THIS here on stackoverflow. The difference to my problem is that in this case new objects are created - my question is now how to deal with this situation when objects get removed (deleted from list).
How massive will be the difference of performance using one or the other implementation?