# Remove Explicit Call To super()
# Description
If a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass. Hence, there is no need to explicitly call the default constructor of the super class.
# Benefits
Improves the readability by removing unnecessary lines of code.
# Tags
Tags
# Code Changes
Pre
class Parent {
public Parent() {
initParent();
}
}
class Child extends Parent {
public Child() {
super();
initChild();
}
}
Post
class Parent {
public Parent() {
initParent();
}
}
class Child extends Parent {
public Child() {
initChild();
}
}
You Want To Have Those Changes Done Automatically?
The automatic application of this rule is supported in the following jSparrow version:
# Properties
Property | Value |
---|---|
Rule ID | RemoveExplicitCallToSuper |
First seen in jSparrow version | 2.7.0 |
Minimum Java version | 1.1 |
Remediation cost | 1 min |