上級 › is not abstract and does not override の原因と直し方 › パターン3
is not abstract and does not override の原因と直し方
抽象メソッドの実装漏れ。
1 interface Greeter { 2 void greet(); 3 } 4 public class Main implements Greeter { 5 _________ void greet() { System.out.println("hi"); } ^ 6 public static void main(String[] args) { 7 new Main().greet(); 8 } 9 }
Main.java:5: error: greet() in Main cannot implement greet() in Greeter
attempting to assign weaker access privileges; was public
空欄を埋めてビルドを通す
インターフェースのメソッドは暗黙にpublicです。実装側でpublicを省くとパッケージ内限定になり狭まります。
次の問題