John Meehan wrote:Finally I'm trying to stick all of these in an enumeration, since I've got a limited number of separate objects that need to be represented, and this way I can (hopefully) create instances of each object in a single class instead of one for each type of object.
First, do you mean an '
enum' (ie, a subclass of java.lang.Enum), or an '
Enumeration' (ie, a java.util.Enumeration)? It sounds like the first.
But, I'm running into a wall. Normally you'd have to create the ArrayList, then do Object.add() for each 2D array element of the array list, but as this is an enumeration, I don't really see how to create the ArrayLists for the enumerations.
I think Jesper and Herbert have shown you a couple of ways, but I think my question would be: do you actually want a List? More specifically, will it contain
duplicates?
If not, and assuming that you are talking about an
enum, you might be better off with an EnumSet. It'll also likely be
much faster.
Also, I'm not sure exactly how you're storing these 'pixel' booleans, but you might want to look at a BitSet as an alternative.
Winston