- package cn.baidu.day01;
- public class EnumText {
- public static void main(String []args){
- WeekDay week=WeekDay.MON;//静态类调用。
-
- System.out.println(week.next());
- }
- }
复制代码- package cn.baidu.day01;
- public abstract class WeekDay {
- private WeekDay(){};//把类私有化。
-
- public final static WeekDay SUN=new WeekDay(){
- public WeekDay next(){
- return MON;
- }
- };//内部类是WeekDay的子类,继承WeekDay方法。
- public final static WeekDay MON=new WeekDay(){
- public WeekDay next(){
- return SUN;
- }
- };
- public abstract WeekDay next();
-
- }
复制代码 输出的结果不应该是SUM,怎么是哈希值啊。 |