public enum TrafficLamp{
RED(30){
public TrafficLamp nextLamp(){
return GREEN;
}
},
GREEN(45){
public TrafficLamp nextLamp(){
return YELLOW;
}
},
YELLOW(5){
public TrafficLamp nextLamp(){
return RED;
}
};
public abstract TrafficLamp nextLamp();
private int time;
private TrafficLamp(int time){this.time = time;}
}
}
3.静态导入
import static java.lang.Math.*;
public class StaticImport {
public static void main(String[] args){
int x = 1;
try {
x++;
} finally {
System.out.println("template");
}
System.out.println(x);