Class without no-arg constructor
Reports classes without a constructor that takes no arguments (i.e. has no parameters). No-arg constructors are necessary in some contexts. For example, if a class needs to be created using reflection.
Example:
public class Bean {
private String name;
public Bean(String name) {
this.name = name;
}
}
Use the checkbox below to ignore classes without explicit constructors. The compiler provides a default no-arg constructor to such classes.
Inspection options
Option | Type | Default |
---|---|---|
Ignore if class has default constructor | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023