Inspectopedia Help

Redundant no-arg constructor

Reports unnecessary constructors.

A constructor is unnecessary if it is the only constructor of a class, has no parameters, has the same access modifier as its containing class, and does not perform any initialization except explicitly or implicitly calling the superclass constructor without arguments. Such a constructor can be safely removed as it will be generated by the compiler even if not specified.

Example:

public class Foo { public Foo() {} }

After the quick-fix is applied:

public class Foo {}

Use the inspection settings to ignore unnecessary constructors that have an annotation.

Inspection options

Option

Type

Default

Ignore constructors with an annotation

Checkbox

false

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023