Java枚举(Enum)的简单使用
public enum Test {
SUCCESS("000000", "success"),
FAILURE("100000", "failure"),
ILLEARG("100001", "illegal argument"),
UNAUTH("200000", "not permitted");
private final String desc;
private final String code;
Test(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
测试
public class TestEnum {
public static void main(String[] args) {
System.out.println(Test.SUCCESS.getCode());
}
}
结果
结果:000000