Java How to call method of grand parents?

Posted by Arkaha on Stack Overflow See other posts from Stack Overflow or by Arkaha
Published on 2010-04-06T11:23:41Z Indexed on 2010/04/06 11:33 UTC
Read the original article Hit count: 302

Filed under:
|
|

Let's assume I have 3 classes A, B and C, each one extending the previous one.

How do I call the code in A.myMethod() from C.myMethod() if B also implements myMethod?

class A
{
  public void myMethod()
  {
    // some stuff for A
  }
}

class B extends A
{
  public void myMethod()
  {
    // some stuff for B
    //and than calling A stuff
    super.myMethod();
  }
}

class C extends B
{
  public void myMethod()
  {
    // some stuff for C
    // i don't need stuff from b, but i need call stuff from A
    // something like: super.super.myMethod(); ?? how to call A.myMethod(); ??
  }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about override