public class Fu8 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Weekday2 weekday2=Weekday2.sun;
System.out.println(weekday2.nextDay());
System.out.println("-----------------------------");
}
}
abstract class Weekday2{
private Weekday2(){}
public final static Weekday2 sun=new Weekday2(){
@Override
public Weekday2 nextDay() {
// TODO Auto-generated method stub
return mon;
}
};
public final static Weekday2 mon=new Weekday2(){
@Override
public Weekday2 nextDay() {
// TODO Auto-generated method stub
return sun;
}
};
public abstract Weekday2 nextDay();
@Override
public String toString() {
return (this==sun)?"sun":"mon";
}
}
|
|