CKTIS / Java
super — superclass access
super — superclass access: super selects a constructor, hidden field, or overridden method of the current object’s direct superclass; fields are hidden, not overridden. InterfaceName.super.m() selects a direct superinterface method.
Version: Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Syntax
supersuper selects a constructor, hidden field, or overridden method of the current object’s direct superclass; fields are hidden, not overridden. InterfaceName.super.m() selects a direct superinterface method.
Invoke super(...) as the first constructor statement in Java 21, use super.m() to extend behavior, and InterfaceName.super.m() to choose an inherited default method.
super is not a separate object and does not disable dynamic dispatch for further calls made inside the superclass method.
If a constructor has no explicit this(...) or super(...), the compiler inserts super(); qualified Outer.super applies to inner-class inheritance.
Child passes Ada through super(name), and its override extends super.label() to produce base:Ada:child.
Examples
public class Main {
static class Base {
private final String name;
Base(String name) { this.name = name; }
String label() { return "base:" + name; }
}
static class Child extends Base {
Child(String name) { super(name); }
@Override String label() { return super.label() + ":child"; }
}
public static void main(String[] args) {
System.out.println(new Child("Ada").label());
}
}
Result
base:Ada:child
Child passes Ada through super(name), and its override extends super.label() to produce base:Ada:child.