当你写一个枚举类时,如果没有在枚举类的第一行写有哪些枚举值,那么就会出现编译报错:Syntax error on token "String", strictfp expected
比如:
public enum Season2 implements TimeInfo {
private final String name; //此处会报错:Syntax error on token "String", strictfp expected
private final String desc;
private Season2(String name, String desc) {
this.name = name;
this.desc = desc;
}
······
}
报错的原因就是没有在第一行写明你有哪些枚举值,修改如下:
public enum Season2 implements TimeInfo {
SPRING,SUMMER,FALL,WINTER; //列出你要定义的枚举值,此时编译通过
private final String name;
private final String desc;
private Season2(String name, String desc) {
this.name = name;
this.desc = desc;
}
······
}