DK1.5 introduces a new type--enumeration. In Java it is a "small" function, but to my development has brought "big" convenience.
usage One: Constants
Before JDK1.5, we defined constants as: publicstaticfianl ... Now that you have enumerations, you can group related constants into an enumeration type, and enumerations provide more methods than constants.
public enum Color {RED, GREEN, BLANK, yellow}
usage two: switch
The switch statement before JDK1.6 only supports the Int,char,enum type, and using enumerations makes our code more readable.
enum signal { green, yellow, red } public class trafficlight { Signal color = Signal.RED; public void change () { switch (color) { case red: color = Signal.GREEN; break; case yellow: color = Signal.RED; break; case green: color = Signal.YELLOW; break;        &NBSP} } }
usage Three: Add a new method to the enumeration
If you intend to customize your own method, you must add a semicolon at the end of the sequence of enum instances. and Java requirements must first define an instance of an enum.
The public enum Color {red ("red", 1), Green ("green", 2), BLANK ("White", 3), Yello ("Yellow", 4); Member variable private String name; private int index; Construction method