/*1、 自定义枚举 Week 用于表示星期,Mon,Tue,Wed...
要求每个枚举值都有toLocaleString 方法,
* 用于获得枚举所表示的星期的中文格式 星期一、星期二、星期三...
* */
package com.itheima;
public class Test1 {
public static void main(String[] args) {
WeekDay weekDay = WeekDay.MON;
System.out.println(weekDay.toString());
}
}
abstract class Week
{
public abstract WeekDay toLocaleString();
}
enum WeekDay
{
//SUM,MON,TUE,WED,THI,FRI,
public void getMON()
{
new WeekDays("星期一")
{
public WeekDay toLocaleString()
{
}
};
}
public final static WeekDay TUE=new WeekDay()
{
};
public final static WeekDay WED=new WeekDay()
{
};
public final static WeekDay THI=new WeekDay()
{
};
public final static WeekDay FRI=new WeekDay()
{
};
public final static WeekDay SAT=new WeekDay(){
};
public final static WeekDay SUM=new WeekDay(){
};
} |
|