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();
		}
		
	}
}

posted @ 2023-08-11 15:54  N0zoM1z0  阅读(1)  评论(0编辑  收藏  举报