建立枚举经常使用有两种方法this
一:直接建立一个枚举类spa
public enum MailType {
toDoMail("a"),chartMail("b"), reportMail("c");get
private String tempAddr;it
//建立构造方法class
private MailType(String tempAddr) {
this.tempAddr = tempAddr;
}
public String getTempAddr(){方法
return this.tempAddr;static
}chart
}di
该类的使用:MailType.toDoMail.getTempAddr();返回的为avi
二:
package com.credithc.workorder.manage.task.entity.caifu;
public class ActivitiParamter{
/**
* 处理状态
* 0:不经过 1:经过
*/
public static final String WO_STATUS="status";
public static enum STATUS {
YES("1", "经过"), NO("0", "不经过");
private String key;
private String value;
//该枚举的构造方法
private STATUS(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
该枚举类的使用:ActivitiParamter.WO_STATUS,返回的是status
ActivitiParamter.STATUS .NO.getKey()返回的是“不经过”