首页 > 代码库 > 自己封装的类,模仿枚举类
自己封装的类,模仿枚举类
package com.javasort;
/**
*一个类只能有四个固定的对象 且属性固定的实现
*/
public class Season {
private final String SEASON_NAME;
private final String SEASON_DESC;
private Season(String seansonName, String seansonDesc) {
//super();
this.SEASON_NAME = seansonName;
this.SEASON_DESC = seansonDesc;
}
static final Season spring=new Season("春天","春风吹过大地");
static final Season summer =new Season("夏天","骄阳似火");
static final Season autumn =new Season("秋天","秋水共长天一色");
static final Season winter =new Season ("冬天","千树万树梨花开");
public String getSEASON_NAME() {
return SEASON_NAME;
}
public String getSEASON_DESC() {
return SEASON_DESC;
}
}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。