I have ClassA which has a static ArrayList of Objects
public static ArrayList<Meteorit> meteorits = new ArrayList<Meteorit>();
Now I want to remove an object from this list like this
ClassA.meteorits.remove(this);
This is written in Meteorit class . But it throws exception when I want to use the objects in the ArrayList .
Exception in thread "LWJGL Application" java.util.ConcurrentModificationException
I used Iterator to remove objects from ArrayList but now I dont have an idea how to use it in this case.
static? I suggest to do it exactly like howobserverdesign pattern did. First, make a method insideClassAcall itpublic removeMetorit(Meteorit meteorit)and use it from wherever exept theMeteoritclass.removemethod from inside the object to be removed and this is illegal.