Uses of super in Java
This collection of articles coers various uses of super in Java.
-
Calling super()
super() calls the constructor of the base class. The call to super() must be the first statement in the constructor. If you provide arguments to super(), it will call base class constructor with the corresponding signature.
-
Calling super.someMethod()
super.someMethod() calls the someMethod implementation of the base class. It is often used to invoke the original implementation when overriding a method.
-
Calling super method of outer class from inner class
To call a super method of an outer (enclosing) class from an inner (nested) class you use the syntax OuterClass.super.method(). This article provides example code.
- Calling a default interface method from implementing class