Is there any way to skip java inheritance hierarchy and call method of super super class?
I have 3 classes in java
X
Y extends X
Z extends Y.
Now is there any way to access any method of X directly skipping Y ?
Is there any way to skip java inheritance hierarchy and call method of super super class?
I have 3 classes in java
X
Y extends X
Z extends Y.
Now is there any way to access any method of X directly skipping Y ?
 
    
     
    
    Here Why is super.super.method(); not allowed in Java? They claim you cannot and there's a good discussion of why.
edit I'm assuming you have a situation like foo() is defined in X and Y and you want to call it from X in Z
 
    
     
    
    Now is there any way to access any method of X directly skipping Y?
Practically no, theoritically yes. Following your example:
X
Y extends X
Z extends Y.
When you call a method of Z, it will call super() which will call method of Y if any and it will call super() too, which will call method of X in the end. I said yes, when method of Y does nothing different from X's, then it is as if it has no effect. But in practice, JVM follows the inheritance hierarchy to complete the calls, bear in mind that.
