Ok so im writting this game and I so far the world is randomly generated, this means that vegetation(trees, plants etc.)spawn all over the place. To prevent overlapping I created a method that would delete one “vegetation” if its touching another as seen in the source code below:
for (Vegetation c: Object_Control.Vegetationarray) {
for (Vegetation i: Object_Control.Vegetationarray) {
if (c.getImageBounds().intersects(i.getImageBounds())) {
Object_Control.removeVegetation(c);
}
}
}
The “getImageBounds()” method returns a rectangle that is the same size as the image.
The error I seem to be getting is:
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
I am happy to supply any more source code related to the issue if needed