3. Months expressed as Enumeration Values.

Listing 3. Months expressed as Enumeration Values.


public final class Month ...
{
    public static final Month january = new Month(1);
    ...
    public static final Month december = new Month(12);
    public int getValue() { return value; }
    ...
    private Month(int month) { value = month; }
    private final int value;
}

About the Author

Kevlin Henney is a Principal Technologist with QA Training in the UK.