8.11 Java enum
enum Color{
RED,GREEN,BLUE;
private Color() {
Mine.pln("Constructor called for : " + this.toString());
}
public void ColorInfo() {
Mine.pln("Universal color");
}
}
public class Mine {
static <T> void pln(T x) {
System.out.println(x);
}
public static void main(String[] args) {
for(Color color : Color.values()) {
Color c = color;
pln(c);
c.ColorInfo();
}
}
}