I have a bunch of different enemy classes that move and behave differently, and often more than one instance of them is spawned on the screen as it's essentially all random, so I need to use an ArrayList so that I can control the behaviour of each individual enemy class.
But, this leaves me with a bunch of ArrayLists like this:
//Example:
ArrayList<Enemy1> enemies = new ArrayList<Enemy1>();
ArrayList<Enemy2> enemies = new ArrayList<Enemy2>();
ArrayList<Enemy3> enemies = new ArrayList<Enemy3>();
ArrayList<Enemy4> enemies = new ArrayList<Enemy4>();
ArrayList<Enemy5> enemies = new ArrayList<Enemy5>();
Is there any way to change the kind of data the ArrayList will store so that I can just empty and re-use different instances of the same ArrayList? Or anything, just so I don't have to have a billion ArrayLists in my code?
Additional info: I'm doing this using the Java Processing library, not sure if it changes anything.
Sorry if the answer is blatantly obvious to you, please don't be rude.