如果我通过了A,如何获得Apple的值...
public enum Enumtype {
A("Apple"), B("Ball"), C("Cat");
private String value;
private Enumtype(String value) {
this.value = value;
}
}
最佳答案
您需要在枚举中添加一个 setter/getter :
public String getValue(){
return this.value;
}
关于java - java中如何从Enum中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36272659/