Java: Calling super.someMethod()

super.someMethod() calls someMethod of the base class. It is often used in an overriding method.

Here's an example:

dog.beHappy(); class Dog extends Animal { void beHappy() { super.beHappy(); print("Wag tail"); } } class Animal { void beHappy() { print("Smile"); } }

You can of course call super.someMethod() anywhere from the subclass. This will "bypass" any overridden version of the method.

You can not reach in to the base class of the base class by doing super.super.someMethod().

Not to be confused with

Comments

Be the first to comment!