0

Well, we all know that we can use the function of father class with "super", but how to use a function of grandfather class? Using "super.super" has no effects. I'm a new Java learner, thanks for your response.

3
  • 1
    Show some code. Commented Aug 8, 2020 at 3:05
  • Well, I do not want to get an answer like "Add a function linked to grandfather class in father class." I want a solution in current class, although I don't know whether there exists a method. Commented Aug 8, 2020 at 3:11
  • I'm not 100% positive your question is a duplicate, but what you specifically describe (i.e. super.super) is deliberately not possible (as explained in the duplicates). And there's no other way to directly call a superclass' superclass' implementation of an overridden method when said method is overridden in each ancestor class (if there was a way, it would have been super.super). Commented Aug 8, 2020 at 4:02

1 Answer 1

1

What you are asking is not possible, it is not allowed by Java language (though allowed by JVM).

One way would be to add a super call in your parent as well, so calling super from child, will call super of parent which will call the method you need in grandparent. Thats what came to my mind.

If you do not want to touch your parent class, and want a solution only in child class, it is not possible. I would suggest changing your class designs.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.