首先我们先定义一个枚举类型的返回结果,代码如下:
enum ResultEnum{
SUCCESS("1","操作成功"),
FAILED("-1","操作失败"),
WARN("0","警告");
private String stateCode;
private String message;
ResultEnum(String stateCode,String message){
this.stateCode = stateCode;
this.message = message;
}
public String getStateCode() {
return stateCode;
}
public void setStateCode(String stateCode) {
this.stateCode = stateCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
枚举类型和Java类一样也有get和set方法,理论上是可以修改其值的,如下:
public static void main(String[] args) {
System.out.println(SeasonEnum.SPRING.getChinese());
System.out.printl