0

my Java (libgdx) application/game throws me java.util.ConcurrentModificationException.

My code:

for (Lod lod : lode) {
    if (!pause){
        lod.move();
    }
    if (lod.isDestroyed()){
        lode.remove(lod);
    } else {
        lod.draw(game.batch);
    }       
}
koca2000
  • 67
  • 12
  • 1
    Take a look at [`ConcurrentModificationException`](http://docs.oracle.com/javase/8/docs/api/java/util/ConcurrentModificationException.html) javadoc to see when this exception is thrown. – Tunaki Aug 28 '15 at 12:59
  • It'd be helpful to view more of your code than just this block.. – ryekayo Aug 28 '15 at 13:00
  • [This](http://www.javacodegeeks.com/2011/05/avoid-concurrentmodificationexception.html) article will tel you more about your problem and solutions which helps to resolve it. – drgPP Aug 28 '15 at 13:01

1 Answers1

0

You try to remove an element while you are iterating over the collection. This is simply not possible by the iterator.

M. Reif
  • 866
  • 7
  • 20