package cn.itcast_04; import org.junit.Test; /* * 如何定义枚举的构造方法和字段 * */ public class EnumDemo2 { @Test public void test(){ print(Grade.B); } public void print(Grade a) { String value = a.getValue(); System.out.println(value); } } enum Grade{ A("100-90"),B("89-80"),C("79-70"),D("70-60"),E("59-0"); private String value; private Grade(String value){ this.value = value; } public String getValue(){ return this.value; } }
by: 发表于:2017-05-25 13:47:08 顶(0) | 踩(0) 回复
??
回复评论