Java: How to invoke a superclass version of an Overridden method?

Community ForumCategory: JavaJava: How to invoke a superclass version of an Overridden method?
matheusdba Staff asked 2 months ago

How to invoke a superclass version of an Overridden method?

1 Answers
matheusdba Staff answered 2 months ago

To invoke a superclass method that has been overridden in a subclass, you must either call the method directly through a superclass instance or use the super prefix in the subclass itself. From the point of view of the subclass, the super prefix provides an explicit reference to the superclass’ implementation of the method.

// From subclass
super.overriddenMethod();