I have 2 separate array lists. one called spawnList and another called foundList
I have the code run through, it spawns an entity and adds said entity ID to the spaw
Have you ever wrote the code
spawnList = foundList
or foundList = spawnList
?
If so, since an ArrayList
is an object you weren't actually copying those lists, you were making them reference the same object. (IE everything you do to one will be done to the other).
If you want to mitigate against this instead of directly setting the lists equal to each other you could do something like
foundList = new ArrayList<>(spawnList)
as this will make the two arrays be separate objects.
Depending on what type of objects are in your arrays this could still be a problem, as they would still be the same instances of each object.