Language syntax
Java Superclass constructor invocation
Invokes a matching accessible constructor of the direct superclass. In Java 21 this explicit invocation is first; Java 25 permits a restricted prologue.
Formal Syntax & Structure
java syntaxjava
super(weight);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()); }}