我正在实现一个接口(interface):
public interface Consultant {
// some documentation here explaining it should throw 3 types of exceptions
CellLocation suggest(GameBoard gameBoard);
}
它使用另一个接口(interface):
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;
}
}
但是我得到了错误
当然,由于界面的原因,我无法将其从公共(public)更改为其他任何内容。
可能是什么原因?我在这里或网上都找不到答案,可能是因为它带来了有关访问修饰符的基本信息。我正在使用Eclipse Neon。
最佳答案
好的,我发现了错误...我在YourConsultant:D之前的几行中悬空了一个孤独的“私有(private)”标签。您的评论很有帮助,特别是要求提供最小,完整和可验证的示例的评论
关于java - 该方法只能设置公共(public)/ protected /私有(private)中的一种,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39469018/