how to get the ENUM from the string value
This question already has an answer here:
public enum Signal{
...
public static Signal byValue(String value) {
Singal[] signales = Signal.getEnumConstants();
for (Signal s:signals) {
if (s.getValue().equals(value) {
return s;
}
}
}
}
链接地址: http://www.djcxy.com/p/38098.html
上一篇: 如何将命令行参数与枚举一起使用?
下一篇: 如何从字符串值中获取ENUM