本帖最后由 张峰 于 2011-11-30 13:15 编辑
package cn.itcast.day1;
public class EnumTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
weekday weekday = weekday.MON;
System.out.println(weekday.nextday());
}
}
package cn.itcast.day1;
public class weekday {
private weekday(){}
public final static weekday SUN = new weekday();
public final static weekday MON = new weekday();
public weekday nextday(){
if (this == SUN){
return MON;
}else{
return SUN;
}
}
public String toString(){
return this==SUN?"SUN":"MON";
}
}
红色区域提示错误是:The local variable weekday may not have been initialized
没被初始化? |