I am new to java and now I am trying to see if its possible to get ENUM from the string value it is assigned.
Consider for example i have this below ENUM ( i have corrected to give complete structure)
public enum Signal{
RED("stop"), GREEN("start"), ORANGE("slow down");
private String value;
private Signal(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
Is it possible to determine ENUM if i have the value which is assigned to it. That is is possible to get RED if i have "stop"
When i searched in internet the "valueof" is discussed which is not what i need as it helps the different purpose. Any reference would be greatly appreciated as well. Thank you for reading!!