gpt4 book ai didi

Java: "error: cannot access"接口(interface)

转载 作者:行者123 更新时间:2023-11-30 02:52:40 26 4
gpt4 key购买 nike

所以我有这个Annotator接口(interface):

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]

有什么想法我哪里出错了吗?

最佳答案

java 类实现接口(interface),而不是扩展接口(interface)。

您应该使用此类定义:

public class GazetteerViewGenerator implements Annotator {
public static final GazetteerViewGenerator gazetteersInstance;
...
}

关于Java: "error: cannot access"接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38176806/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com