本帖最后由 谢波 于 2013-2-21 13:05 编辑
- public class EnumTest {
- public static void main(String[] args) {
- WeekDay w = WeekDay.TUS;
- System.out.println(w);
- System.out.println(w.nextDay());
- }
- //枚举
- public enum WeekDay{
- SUN(){
- public WeekDay nextDay(){
- return MON;
- }
- },MON(){
- public WeekDay nextDay(){
- return TUS;
- }
- },TUS(){
- public WeekDay nextDay(){
- return SUN;
- }
- };
- private WeekDay(){}
- public abstract WeekDay nextDay();
- }
复制代码 运行后,发现有 5 个class文件
EnumTest.class
EnumTest$WeekDay.class
EnumTest$WeekDay$1.class
EnumTest$WeekDay$2.class
EnumTest$WeekDay$3.class
那也就是说在WeekDay类里面还有3个匿名内部类
但是没见过这样的匿名内部类啊,求详解。。。 |