日期:2014-05-20  浏览次数:20692 次

java 枚举 两个数字代表一个字符串
枚举如何实现

比如0和0代表一个字符串"No additional information"
0和1代表一个字符串"xx xx xx" 等等

枚举用的少

如能解答,谢谢各位
------解决方案--------------------
本帖最后由 fangmingshijie 于 2014-03-31 15:55:17 编辑
供参考,使用直接ABC.values();

public enum ABC {
A(00, "AAA"), B(01, "BBB");
private int ordial;
private String value;

private ABC(int ordial, String value) {
this.ordial = ordial;
this.value = value;
}

private ABC() {
}

public int getOrdial() {
return ordial;
}

public void setOrdial(int ordial) {
this.ordial = ordial;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

}



------解决方案--------------------
http://www.iteye.com/topic/1116193