import java.util.EnumSet;
public enum ColorEnum {
RED("red"),GREEN("green"),BLUE("blue"),OTHER("other");
private String color;
private ColorEnum(String color){
this.color = color;
}
public String getColor(){
return color;
}
public static void printColor(ColorEnum ce){
System.out.println(ce.getColor());
switch(ce){
case RED:
System.out.println("red");
break;
case BLUE:
System.out.println("blue");
break;
case GREEN:
System.out.println("green");
break;
default:
System.out.println("no color");
}
}
public static ColorEnum getColor(String color){
return Enum.valueOf(ColorEnum.class,color);
}
public static void showIno(){
for(ColorEnum ce:ColorEnum.values()){
System.out.println(ce.getColor());
}
}
public static void testEnumSet(){
EnumSet<ColorEnum> set = EnumSet.allOf(ColorEnum.class);
for(ColorEnum ce:set){
System.out.println(ce.getColor());
}
}
}