J'ai un petit soucis avec une itération d'ArrayList qui me renvoie un ConcurrentModificationException
Comment corriger cette exception ?
Note :il n'y a aucun Thread dans le programme donc il n'y a qu'un seul accès à la fois à l'arraylist
for(int rx=10;rx<tailleGrille-10;rx++){
for(int ry=10;ry<tailleGrille-10;ry++){
if(!grille[rx][ry].isEmpty()){
Iterator it = grille[rx][ry].iterator();
while(it.hasNext()){
try{
Entite objet=(Entite) it.next();
String strType ;
strType = (objet.getClass().getName());
if(strType.compareTo("Vide")==0){
grille[rx][ry].remove(objet);
}
}
catch(NoSuchElementException exc){};
}
}
}
}