public enum SimpleColor { RED, GREEN, BLUE } public static void main(String[] args) { for (SimpleColor sc : SimpleColor.values()) { System.out.println(sc); } }
In addition, you may also using it as following:
public enum ComplexColor { RED ("Red", "0XFF0000"), GREEN ("Green", "0X00FF00"), BLUE ("Blue", "0X0000FF"); private String title; private String rgb; ComplexColor(String title, String rgb) { this.title = title; this.rgb = rgb; } public String title() { return title; } public String rgb() { return rgb; } } public static void main(String[] args) { for (ComplexColor cc : ComplexColor.values()) { System.out.println(cc.title() + " - " + cc.rgb()); } }
so, you can have more information on it.