Quando compilo questo codice:
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"; } }
Ottengo il seguente errore:
Camel.java:13: error: getGait() in Camel cannot implement getGait() in Rideable String getGait() { ^ attempting to assign weaker access privileges; was public 1 error
Come viene dichiarato il metodo getGait nell’interfaccia considerato pubblico?