interface Rideable {
String getGait();
}
public class Camel implements Rideable {
String getGait() { return " mph, lope"; }
}
Why does the compilation fail? I really don't know why the compile error?
interface Rideable {
String getGait();
}
public class Camel implements Rideable {
String getGait() { return " mph, lope"; }
}
Why does the compilation fail? I really don't know why the compile error?
By default the modifier for interface's method is public. So when you implement it. It need to be public. Add public to your getGait method should resolve it
Methods in interface are by default public and abstract and data member are by default public, static and final as access label. In subclass implementation, you have not mentioned any modifier. So it will have default access. While giving the implementation you can't restrict(provide lesser) the access label. So you have to provide public as access modifier while implementing the methods of interface.