我遇到过这个问题的大多数人都在使用=
,他们需要==
。这里导致我的问题是什么?比较枚举值时出现“意外类型”错误
com\callmeyer\jopp\FieldCoordinator.java:303: unexpected type required: class, package found : variable if (event.getType() == event.Type.INSERT) { ^
枚举定义和存取:
public class DataLayoutEvent {
public static enum Type { INSERT, DELETE, RENAME, MOVE, RESIZE }
private Type type = null;
public Type getType() {
return type;
}
...
}
,并且其中发生错误的方法,包括:
public void layoutChanged(DataLayoutEvent event) {
if (event.getType() == event.Type.INSERT) {
fieldAdded(event.getField(), event.getToIndex());
}
...
嗯,我想我所用的非静态的快捷方式之前成功。也许这只适用于静态字段,而不是嵌套类和枚举。 –
@bemace正好。 –