2016-07-04 73 views
0

所以我有這個Annotator接口:的Java:「錯誤:無法訪問」的接口

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] 

任何想法,我哪裏出錯了?

回答

3

java類implements接口而不是extends它。

你應該使用這個類的定義:

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