0
0

More than 1 year has passed since last update.

private method of interface

Posted at

default methodからprivate methodを利用する

interface A {
    private void privateMethod() {
        System.out.println("aaaaprivate");
    }
    default void method() {
        System.out.println("aaaaA");
        privateMethod();
    }
}

class C implements A{
    public void method() {
        A.super.method();
    }
}
public class Outer {
    public static void main(String[] args) {
      new C().method();
    }
}
aaaaA
aaaaprivate
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0