- 枚举: 就是java内部的数据表
- ONE(1,“齐”)
- 相当于: one表中的 id, name 两列。
- 表名: one
- id name
- 1 齐
- 也可以多列:也就是表中的4个字段
- id name adress age
- 1 齐 中国中原地区 20
CountryEnum.java
public enum CountryEnum {
ONE(1,"齐"), TWO(2,"楚"), THREE(3,"燕"), FOUR(4,"韩"),FIVE(5,"赵"),SIX(6,"魏");
private Integer retCode;
private String retMessage;
public Integer getRetCode() {
return retCode;
}
public String getRetMessage() {
return retMessage;
}
CountryEnum(Integer retCode, String retMessage) {
this.retCode = retCode;
this.retMessage = retMessage;
}
public static CountryEnum getCountry(int index){
CountryEnum[] countryEnums = CountryEnum.values();
for (CountryEnum element: countryEnums) {
if(index == element.getRetCode()){
return element;
}
}
return null;
}
}