Skip to main content
1 of 3
davewp
  • 111
  • 3
public class Main {  
  public static void main(String[] args) {
    new B();
  }

   static class A {       
        public void foo() { 
            try {
                Method m = this.getClass().getSuperclass().getMethod("foo", null);
                m.invoke(this, null);
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    static class B extends A {
        B() { foo(); }
        
        public void foo() { super.foo(); }
    }
}
davewp
  • 111
  • 3