枚举
作者:互联网
public enum Season { Spring("春天","春意盎然"), Summer("夏天","夏日炎炎"), ; private String seasonName; private String seasonDesc; Season(String seasonName, String seasonDesc) { this.seasonName = seasonName; this.seasonDesc = seasonDesc; } public String getSeasonName() { return seasonName; } public void setSeasonName(String seasonName) { this.seasonName = seasonName; } public String getSeasonDesc() { return seasonDesc; } public void setSeasonDesc(String seasonDesc) { this.seasonDesc = seasonDesc; } }
public class TestSeason { public static void main(String[] args) { Season spring = Season.Spring; System.out.println(spring.getSeasonName()+"---"+spring.getSeasonDesc()); } }
标签:String,Season,枚举,seasonName,seasonDesc,spring,public 来源: https://www.cnblogs.com/linlinmailbox/p/16491779.html