本帖最后由 L.I.F.E 于 2013-6-13 18:48 编辑
初学者,不太习惯Myeclipse,所以用EditPlus 写了下代码,但是编译不过。下面上代码:- import java.util.Date;
- abstract class WeekDay
- {
- private WeekDay()
- {
- }
- public final static WeekDay SUN = new WeekDay()
- {
- public WeekDay newDay()
- {
- return MON;
- }
-
- };
- public final static WeekDay MON = new WeekDay()
- {
- public WeekDay newDay()
- {
- return SUN;
- }
- };
- public abstract WeekDay nextDay();
- /*public WeekDay nextDay()
- {
- if (this == SUN)
- {
- return SUN;
- }
- else
- return MON;
- }*/
- public String toString()
- {
- return this == SUN?"SUN":"MON";
- }
- }
- class EnumTest
- {
- public static void main(String[] args)
- {
- WeekDay weekDay1 = WeekDay.SUN;
- System.out.println(weekDay1.toString());
- }
- }
复制代码 报错误说:<匿名WeekDay $1>不是抽象的,并且未覆盖WeekDay中的抽象方法nextDay()。
|
|