So in my game, each room has it’s own arraylist containing a bunch of entities
I’m dealing with this specific room (randomly generated) that has two entities (the exit and the entrance)
Now, it’s VERY important that the objects are in a specific order in the arraylist, because the room-changing-code depends on it
The entrance must be at index 0, and the exit must be at index 1
It’s not normally a problem, but because the room is randomly generated, I can’t control which one (the exit or entrance) is created first
So half of the time, I get an error that I can’t add the exit at index 1 because the size isn’t big enough yet
But here’s the thing, the API ( http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html ) says that when you create an arraylist through the parameter-less constructor (the one I use) it ensures a capacity of ten. So what gives? How can I make sure I can add an object at index 1 before I add one at index 0?
Thanks