枚举与注解


```java
package meiju_and_zhujie;
/*


注解引入:

要求创建季节对象,请设计并完成


//枚举类(Enumeration,简写为enum):
顾名思义:
枚:一个个,举:列举
枚举类:一个个对象列举出来类称为枚举类


 */
public class Enumeration01 {
    public static void main(String[] args){
     Season spring =new Season("春天","温暖");
     Season summer=new Season("夏天","热");
     Season autumn=new Season("秋天","凉爽");
     Season winter=new Season("冬天","寒冷");
     //对于季节而言,只有四个固定的,并且不可以修改
        // 这样的设计不好
        //
     Season other=new Season("红日","~");
    }
}
class Season{
    private String name;
    private String description;
   public Season(String name,String description){
       this.name=name;
       this.description=description;
   }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}

上一篇:mux_xz


下一篇:CF743C Vladik and fractions