枚举
枚举是一个单例类,里面都是常量,对于枚举类也可以直接用类名.对象名来调用里面的方法和属性,枚举的构造方法默认是私有private,其他与类差别不大
public enum Fist {
JIAN_DAO("剪刀",1) {
@Override
public String toString() {
return this.getId() +
"、" + this.getValue() ;
}
}, SHI_TOU("石头",2) {
@Override
public String toString() {
return this.getId() +
"、" + this.getValue();
}
}, BU("布",3) {
@Override
public String toString() {
return this.getId() +
"、" + this.getValue() ;
}
};
Fist() {
}
Fist(String value,Integer id) {
this.value = value;
this.id=id;
}
private String value;
private Integer id;
public String getValue() {
return value;
}
public Integer getId() {
return id;
}
}
标签:return,String,value,public,枚举,id
From: https://www.cnblogs.com/Liku-java/p/16920848.html