枚举类的使用例子

来源:互联网 发布:部落冲突建筑升级数据 编辑:程序博客网 时间:2024/05/16 08:45

枚举类的使用,有构造函数,有函数哟

package com.bird.test;import org.junit.Test;public class EumeTest {@Testpublic void print() {String day;day = Week.MON.getValue();System.out.println(day + Week.MON.getValue1());}}enum Week {MON("星期一") {public String getValue1() {return "this is the first day.";}},TUE("星期二") {public String getValue1() {return "this is the first day.";}},WED("星期三") {public String getValue1() {return "this is the first day.";}},THU("星期四"){public String getValue1() {return "this is the first day.";}},FRI("星期五"){public String getValue1() {return "this is the first day.";}},SAT("星期六"){public String getValue1() {return "this is the first day.";}},SUN("星期日"){public String getValue1() {return "this is the first day.";}};private String value;private Week(String value) {this.value = value;}public String getValue() {return value;}public abstract String getValue1();}


 

运行结果:

星期一this is the first day.


 

原创粉丝点击