public enum EnumTest {
//这里应该全部大写? 但是首字母大写似乎也可以正常使用
Dog("dog","一条狗"),Cat("cat","一只猫");
private final String type;
private final String exp;
//这里定义type和exp的位置
private EnumTest(String type,String exp){
this.type = type;
this.exp = exp;
}
public String getType() {
return this.type;
}
public String getExp() {
return this.exp;
}
}
//调用
EnumTest enumTest = EnumTest.Dog;
System.out.print(enumTest.getType()); //输出dog