What\'s the easiest and/or shortest way possible to get the names of enum elements as an array of Strings?
What I mean by this is that if, for example,
I have the same need and use a generic method (inside an ArrayUtils class):
public static String[] toStringArray(T[] array) {
String[] result=new String[array.length];
for(int i=0; i
And just define a STATIC inside the enum...
public static final String[] NAMES = ArrayUtils.toStringArray(values());
Java enums really miss a names() and get(index) methods, they are really helpful.