1 enum SeasonEnum {//枚举类: 本类规定了SeasonEnum(季节)类只能有四个对象SPRING,SUMMER,AUMUTN,WINTER
 2     //创建枚举类的的四个对象SPRING,SUMMER,AUMUTN,WINTER
 3     //枚举类的实例对象必须在类体的最前面先定义,而且必须每个实例对象都必须维护chinese成员变量
 4     SPRING("春天"),SUMMER("夏天"),AUMUTN("秋天"),WINTER("冬天");
 5     private String chinese;
 6     //枚举类型的构造函数默认为private,因为枚举类型的初始化要在当前枚举类中完成。
 7     SeasonEnum (String chinese){
 8         this.chinese= chinese;
 9     }
10     public String getChinese(){
11         return chinese;
12     }
13 }
14 
15 public class Test{
16     public static void main(String[] args) {
17         //直接初始化
18         SeasonEnum season1 =SeasonEnum.SPRING;
19         //调用SeasonEnum枚举类的getChinese()方法获取SPRING的中文值
20         System.out.println(season1.getChinese());
21     }
22 }
View Code