Redundant field initialization
Reports fields explicitly initialized to their default values.
Example:
class Foo {
int foo = 0;
List bar = null;
}
After the quick-fix is applied:
class Foo {
int foo;
List bar;
}
Use the inspection settings to only report explicit null
initialization, for example:
class Foo {
int foo = 0; // no warning
List bar = null; // redundant field initialization warning
}
Inspection options
Option | Type | Default |
---|---|---|
Only warn on initialization to null | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023