学习了张孝祥老师的枚举后 自己联系了一下 除了这个错误,搞不懂
enum Week
{
MONDAY("星期一"),WEDNESDAY("星期三"),TUESDAY("星期二"),THRSDAY("星期四") ;
private final String name ;
private Week (String name){
this.name = name ;
}
public String getName(){
return this.name ;
}
}
public class EnumTest
{
public static void main(String[] args){
Enum week = Enum.valueOf(Week .class,"星期二 ") ;
System.out.println(week + "代表:" + week .getName()) ;
}
}
编译出错:找不到符 方法getName() ,位置:类型为Enum的变量week
|