繁体   English   中英

该方法只能设置public / protected / private之一

[英]the method can only set one of public / protected / private

我正在实现一个接口:

public interface Consultant {
    // some documentation here explaining it should throw 3 types of exceptions
    CellLocation suggest(GameBoard gameBoard);
}

它使用另一个接口:

public interface GameBoard {
    CellState getCellState(CellLocation cellLocation);
}

我写了很多方法,但刚开始实现了所有重要的建议方法。 到目前为止看起来像这样:

public class YourConsultant implements Consultant {
    @Override
    public CellLocation suggest(GameBoard gameBoard) {
        char[][] arrayBoardGlobal;
        Player currentPlayerGlobal;
        GameState gameStateGlobal;
        return null;
    }
}

但是我得到了错误

方法建议在类型YourConsultant中只能设置public / protected / private之一

当然,由于界面的原因,我无法将其从公共更改为其他任何内容。

可能是什么原因? 我没有在这里或网上找到答案,可能是因为它提供了有关访问修饰符的基本信息。 我正在使用Eclipse Neon。

好吧,我发现了错误......在YourConsultant:D之前,我在悬空中留下了一个孤独的“私人”标签。 您的评论很有帮助,尤其是要求提供最小,完整和可验证示例的评论

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM