自定义枚举中定义两个构造器,反射为什么取出三个构造器?
import java.lang.reflect.*;
enum WeekDay{
SUN(){
public WeekDay nextDay(){
return MON;
}
},MON(){
public WeekDay nextDay(){
return SUN;
}
};
WeekDay(){
System.out.println("first");
}
WeekDay(int x){
System.out.println("second");
}
public abstract WeekDay nextDay();
}
class Run{
public static void main(String[] args){
Constructor[] constructors = WeekDay.class.getDeclaredConstructors();
for(Constructor constructor : constructors){
System.out.println(constructor);
}
}
}
|
|