赞
踩
枚举类:
public enum ContractTempletEnumCopy {
PPT(1), SIGNT(2), UNKNOWN(-1);
private Integer id;
ContractTempletEnumCopy(Integer id) {
this.id = id;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public static ContractTempletEnumCopy valueOf(Integer id) {
ContractTempletEnumCopy[] values = ContractTempletEnumCopy.values();
for(ContractTempletEnumCopy value : values){
if(value.getId() == id){
return value;
}
}
return UNKNOWN;
}
}
测试类:
public class TH_01_JavaEnum {
public static void main(String[] args) {
TH_01_JavaEnum test = new TH_01_JavaEnum();
test.action();
}
public void action(){
ContractTempletEnum test = ContractTempletEnum.valueOf(2);
System.out.println("[1]_" + test);
switch (test) {
case PPT:
System.out.println("[2]_" + test);
break;
case SIGNT:
System.out.println("[2]_" + test);
break;
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。