What\'s the easiest and/or shortest way possible to get the names of enum elements as an array of String
s?
What I mean by this is that if, for example,
Something like this would do:
public static String[] names() {
String[] names = new String[values().length];
int index = 0;
for (State state : values()) {
names[index++] = state.name();
}
return names;
}
The documentation recommends using toString() instead of name() in most cases, but you have explicitly asked for the name here.