Filling a List with all enum values in Java
I wouldn't use a List in the first places as an EnumSet is more approriate but you can do
List<Something> somethingList = Arrays.asList(Something.values());
or
List<Something> somethingList =
new ArrayList<Something>(EnumSet.allOf(Something.class));
There is a constructor for ArrayList
which is
ArrayList(Collection<? extends E> c)
Now, EnumSet
extends AbstractCollection
so you can just do
ArrayList<Something> all = new ArrayList<Something>(enumSet)
Class.getEnumConstants()
List<SOME_ENUM> enumList = Arrays.asList(SOME_ENUM.class.getEnumConstants());