【发布时间】:2016-08-12 06:04:24
【问题描述】:
interface Rideable {
String getGait();
}
public class Camel implements Rideable {
String getGait() { return " mph, lope"; }
}
为什么编译失败?真不知道为什么会出现编译错误?
【问题讨论】:
-
编译错误告诉你什么?
-
你读错了吗?
-
接口方法默认是公开的。您正在尝试使用包私有方法(更具限制性)来实现该方法。请参阅 this chart 了解公共和包私有之间的比较。
标签: java variables interface scope access-modifiers