01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package subclass.ex9;

public class M {
  public static void main(String[] argv) {
    O o = new X();
    I i = o.getI();
    i.m();
  }
}
interface I { public void m(); }
class O {
  void p() {System.out.println("O.p");}
  I getI() {
    //return () -> O.this.p();
    return new I() {
      public void m() {
        O.this.p(); // static or dynamic binding?
      }};
  }
}
class X extends O {
  void p() {System.out.println("X.p");}
}