In the latest version of the Inheritance tutorial - Polymorphism article at https://dev.java/learn/inheritance/polymorphism/ (archived as is at https://web.archive.org/web/20260424021350/https://dev.java/learn/inheritance/polymorphism/ ),
it is stated
Invocation of a superclass constructor must be the first line in the subclass constructor.
Which has been true, but is now out of date as of Java 25 with the release of "JEP 513: Flexible Constructor Bodies" ( https://openjdk.org/jeps/513 ).
Per JEP 513:
Status Closed / Delivered
Release 25
[...]
In the body of a constructor, allow statements to appear before an explicit constructor invocation, i.e., super(...) or this(...). Such statements cannot reference the object under construction, but they can initialize its fields and perform other safe computations.
See also https://docs.oracle.com/en/java/javase/25/language/flexible-constructor-bodies.html .
In the latest version of the Inheritance tutorial - Polymorphism article at https://dev.java/learn/inheritance/polymorphism/ (archived as is at https://web.archive.org/web/20260424021350/https://dev.java/learn/inheritance/polymorphism/ ),
it is stated
Which has been true, but is now out of date as of Java 25 with the release of "JEP 513: Flexible Constructor Bodies" ( https://openjdk.org/jeps/513 ).
Per JEP 513:
See also https://docs.oracle.com/en/java/javase/25/language/flexible-constructor-bodies.html .