其他分享
首页 > 其他分享> > 枚举与注解

枚举与注解

作者:互联网


```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;
    }
}

标签:description,Season,name,枚举,new,注解,public,String
来源: https://blog.csdn.net/m0_52629611/article/details/121399013