看下这段代码,张老师基础加强视频中第13个视频中的,老师一直强调是子类,如下:求解???
class EnumTest
{
public static void main(String[] args)
{
WeekDay weekDay = WeekDay.SUN;
System.out.println(weekDay.toString());
System.out.println(weekDay.nextDay());
}
}
class abstract WeekDay
{
private WeekDay(){}
public static final WeekDay SUN=new WeekDay() //问下,这里是在子类中复写方法吗??老师在强调子类,可是我怎么没有看出new WeekDay(){}是个子类啊??这不是对象吗??
{
public WeekDay nextDay()
{
return MON;
}
};
public static final WeekDay MON=new WeekDay()
{
public WeekDay nextDay()
{
return SUN;
}
};
public abstract WeekDay nextDay(); |