我在java中有一个枚举类如下
public enum SMethod {
/**
* LEAVE IN THIS ORDER
*/
A (true, true, true,false),
B (true, true, false,false),
C (true, true, false,false),
D (false, false, false)
}
另一个类有下面的方法
private String getSMethod(boolean isSds) {
if (isClsSds)
return "A";
else
return "B";
}
目前此方法返回硬代码值但字符串。但我想使用 SMethod 枚举返回它。我已将其编写如下:
private SMethod getSMethod(boolean isSds) {
if (isClsSds)
return SMethod.A;
else
return SMethod.B;
}
但我的需要是这个方法应该返回字符串。
最佳答案
关于java - 如何从java中的枚举中获取名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16141810/