Language syntax

Java Superclass method invocation

Calls the selected superclass implementation rather than dispatching to the current override.

Formal Syntax & Structure

java syntaxjava
super.fee()

Working Example

Example Snippetjava
class Parcel {    private final int weight;    Parcel(int weight) {        if (weight <= 0 || weight > 100) throw new IllegalArgumentException("weight");        this.weight = weight;    }    public int weight() { return weight; }    public int fee() { return weight * 20; }}class ExpressParcel extends Parcel {    ExpressParcel(int weight) { super(weight); }    public int fee() { return super.fee() + 100; }}public class Main {    public static void main(String[] args) {        ExpressParcel parcel = new ExpressParcel(3);        System.out.println(parcel.weight());        System.out.println(parcel.fee());    }}
Java Reference