enum

2020-05-08  本文已影响0人  梁佳凝

enum相当于数据库的表

mysql dbName = CountryEnum

table

one(各表列相同)

ID,username,age

1,一,5

ONE(1,"一",v2)

public enum CountryEnum {

ONE(1,"一","a"),TWO(2,"二","b"),THREE(3,"三","c"),FOUR(4,"四","d"),FIVE(5,"五","e"),SIX(6,"SIX","f");

private IntegerretCode;

private StringretMessage;

private StringretMessage2;

public Integer getRetCode(){

return this.retCode;

}

public String getRetMessage(){

return this.retMessage;

}

public String getRetMessage2(){

return this.retMessage2;

}

CountryEnum(Integer retCode,String retMessage,String retMessage2){

this.retCode = retCode;

this.retMessage = retMessage;

this.retMessage2 = retMessage2;

}

public static CountryEnum foreach_CountryEnum(int index){

CountryEnum[] myArray = CountryEnum.values();

for(CountryEnum ele : myArray){

if(index == ele.retCode){

return ele;

}

}

return null;

}

}

上一篇下一篇

猜你喜欢

热点阅读