当我编译这段代码时:
interface Rideable {
String getGait();
}
public class Camel implements Rideable {
int x = 2;
public static void main(String[] args) {
new Camel().go(8);
}
void go(int speed) {
System.out.println((++speed * x++)
+ this.getGait());
}
String getGait() {
return " mph, lope";
}
}
我收到以下错误:
Camel.java:13: error: getGait() in Camel cannot implement getGait() in Rideable
String getGait() {
^
attempting to assign weaker access privileges; was public
1 error
接口中声明的 getGait 方法如何被认为是公共的?