public final static Numbers ZERO = new Numbers() { //创建Numbers类的子类对象
public Numbers nextNum() {
return ONE;
}
};
public final static Numbers ONE = new Numbers() {
public Numbers nextNum() {
return ZERO;
}
};
@Override
public String toString() {
return this == ZERO ? "ZERO" : "ONE";
}
}
作者: whs_nk 时间: 2013-4-1 17:48
public abstract class Numbers{}, Numbers day = Numbers.ONE;抽象类呐,根据枚举的定义及你的编程意图,那么 Numbers.ONE就是一个枚举的实例了,而抽象类和抽象的接口是不能创建实例的哦