# 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();
}
}
Use a Java Refactoring Tool
No license required
You can review this refactoring on your code without a license by installing jSparrow to your Eclipse IDE. Install the plug-in from Eclipse IDE: Eclipse Marketplace.
System-wide Refactoring
Do you want to automate this refactoring (and many more) to your system-wide code? The automatic application of this system-wide refactoring can be unlocked by acquiring your jSparrow license.
# Properties
Property | Value |
---|---|
Rule ID | RemoveExplicitCallToSuper |
First seen in jSparrow version | 2.7.0 |
Minimum Java version | 1.1 |
Remediation cost | 1 min |