I have an enum declared like this:
public enum Mode{
RUNNING("SytemRunning"),
STOPPED("SystemStopped"),
IDLE("tmpIdle");
public static String key;
private Mode(String key){
this.key = key;
}
}
Now, I want to get out the keys(SystemRunning, SystemStopped, tmpIdle) for this enum by reflection:
Class<?> c = Class.forName("Mode");
Object[] objects = c.getEnumConstants();
// now this is not what I want, but almost
for(Object obj : objects){
System.out.println("value : " + obj);
}
the output is: RUNNING STOPPED IDLE
However, I'd like to have the Strings SystemRunning, tmpIdle etc..
Thank you very much in advance.