1、简单

public enum Signal {
  GREEN, YELLOW, RED
}

  

 

2、复杂

public enum Color {
	RED("红色", 1), GREEN("绿色", 2), BLANK("白色", 3), YELLO("黄色", 4);
	private String name;
	private int 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;
	}

	private Color(String name, int index) {
		this.name = name;
		this.index = index;
	}
	public static Color getColor(int index) {
		Color result = null;
		Color [] colors = values();
		for(int i=0;i<colors.length;i++) {
			Color color = colors[i];
			if(color.index == index) {
				result = color;
				break;
			}
		}
		return result;
	}
}

  

 

3、接口

public interface FeedBackConstant {

	enum Type{
		IPHONE(0,"iphone"),ANDROID(1,"android"),IPAD(2,"android"),ANDROID_PAD(3,"androidpad");
		int index;
		String name;
		public int getIndex() {
			return index;
		}
		public void setIndex(int index) {
			this.index = index;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		private Type(int index, String name) {
			this.index = index;
			this.name = name;
		}

		public static Map<String,Object> generateEnumMap() {
			Map<String,Object> resultMap = new HashMap<String,Object>();
			Type [] typeArr = values();
			for(int i=0;i<typeArr.length;i++) {
			Type type = typeArr[i];
			resultMap.put(Integer.toString(type.getIndex()), type.getName());
			}
			return resultMap;
		}
	}

	enum FeedBackType{

	}
}