Java基础——枚举类型
Demo
public enum Color {
RED(1, "红"),
YELLOW(2, "黄"),
BULE(3, "蓝");
private int code;
private String value;
private Color(int code, String value) {
this.code = code;
this.value = value;
}
public String toString() {
return "code: " + this.code + ", value: " + this.value;
}
public int getCode() {
return this.code;
}
public String getValue() {
return this.value;
}
}理解
扩展
枚举比较
注意点
参考资料
Last updated


