package com.hai.tao;
public enum Color {
REDD("红色", 11), GREENN("绿色", 22), BLUEE("白色", 33), YELLOO("黄色", 44);
private String name;
private int index;
private Color(String name, int index) {
this.name = name;
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
}
package com.hai.tao;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// 遍历所有的枚举
for (Color color : Color.values()) {
System.out.println(color + " " + color.getName() + " " + color.getIndex());
}
}
}
java中的枚举在多人在线游戏后台开发中扮演什么角色昵?
回答是,通常用于消息处理器类的注册
FR:徐海涛(Hunk Xu)