所以我有这个Annotator
界面:
public interface Annotator {
String getViewName();
View getView(TextAnnotation var1) throws AnnotatorException;
String[] getRequiredViews();
}
由GazetteerViewGenerator
扩展:
public class GazetteerViewGenerator extends Annotator {
public static final GazetteerViewGenerator gazetteersInstance;
...
问题在于,当我创建GazetteerViewGenerator
的对象并投射到Annotator
时,它会给我错误,这真的很奇怪:
public class MyCuratorClient {
public static Annotator gazetteers = (Annotator) GazetteerViewGenerator.gazetteersInstance;
...
这是错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project Illinois-Combined-Coref: Compilation failure
[ERROR] /Users/danielk/ideaProjects/Illinois-Combined-Coref/src/main/java/edu/illinois/cs/cogcomp/lbj/coref/util/MyCuratorClient.java:[25,38] error: cannot access Annotator
[ERROR] -> [Help 1]
[ERROR]
我出错的任何想法?
答案 0 :(得分:3)
java类implements
一个接口,而不是extends
它。
您应该使用此类定义:
public class GazetteerViewGenerator implements Annotator {
public static final GazetteerViewGenerator gazetteersInstance;
...
}
答案 1 :(得分:-1)
关于“无法访问...”错误,我发现intelliJ有一个阻止错误,阻止您从更改的包装中刷新。您的代码可能根本没有问题,但是在IDE中用摆动的红线强调。尝试再次重新打开项目,您的问题可能会得到解决,不变。