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 }}