public static final Integer SPRING = 1;
public static final Integer SUMMER = 2;
public static final Integer FALL = 3;
public static final Integer WINTER = 4;
我们可以使用枚举类来表示,这也就是最简单的枚举。
public static SeasonEnum[] values()
{
return (SeasonEnum[])$VALUES.clone();
}
public static SeasonEnum valueOf(String s)
{
return (SeasonEnum)Enum.valueOf(SeasonEnum, s);
}
private SeasonEnum(String s, int i)
{
super(s, i);
}
public static final SeasonEnum SPRING;
public static final SeasonEnum SUMMER;
public static final SeasonEnum FALL;
public static final SeasonEnum WINTER;
private static final SeasonEnum $VALUES[];
static
{
SPRING = new SeasonEnum("SPRING", 0);
SUMMER = new SeasonEnum("SUMMER", 1);
FALL = new SeasonEnum("FALL", 2);
WINTER = new SeasonEnum("WINTER", 3);
$VALUES = (new SeasonEnum[] {
SPRING, SUMMER, FALL, WINTER
});
}
}