public enum TypeEnum {
/**
* 类型 1
*/
T1(1, "类型 1"),
T2(2, "类型 2"),
T3(3, "类型 3");
private final Integer value;
private final String name;
TypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public String getName() {return this.name;}
public Integer getValue() {return this.value;}
}
public class Demo {public static void main(String[] args) {System.out.println( TypeEnum.T2.getValue());
// 2
System.out.println(TypeEnum.T2.getName());
// 类型 2
}
}