Back to Intellij Community

RedundantFieldInitialization

java/java-impl/resources/inspectionDescriptions/RedundantFieldInitialization.html

2025.3-rc-2432 B
Original Source

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
  }