首页 > 代码库 > Enum基础
Enum基础
enum ColorE {
RED, GREEN, BLUE;
}
public class GetEnumContent {
public static void main(String[] args) {
// ColorE color=ColorE.BLUE;
// System.out.println(color);
// for (ColorE c : ColorE.values()) {
// System.out.println(c);
// }
for(ColorE c:ColorE.values()){
print(c);
}
}
public static void print(ColorE color) {
switch (color) {
case RED: {
System.out.println("I AM RRRRRRRRRED.");
break;
}
case GREEN: {
System.out.println("I AM GRREN.");
break;
}
case BLUE: {
System.out.println("I AM BLLLUUUE.");
break;
}
default: {
System.out.println("I DONT KOWN THIS COLOR.");
break;
}
}
}
}
Enum基础