given the following code…
private enum EventTypes {
WORK, BREAK, WAIT, CLOSE, COMPLETE
}
public static void main(String[] args) {
System.out.println("BREAK : " + EventTypes.BREAK);
System.out.println(Arrays.asList(EventTypes.values()).contains("WORK"));
System.out.println(Arrays.asList(EventTypes.values()).contains("WOR"));
}
This produces the output…
BREAK : BREAK
false
false
Now, from the output I can see “BREAK” exists as a String – so why does it believe “WORK” does not exist in the above enum?
Enum values aren’t strings. Do this :
If you want to know if your string is the name of an enum value, do