resources.report.rules.pmd.RedundantFieldInitializer.html Maven / Gradle / Ivy
RedundantFieldInitializer
RedundantFieldInitializer
Java will initialize fields with known default values so any explicit initialization of those same defaults is redundant and results in a larger class file (approximately three additional bytecode instructions per field).
This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.optimizations.RedundantFieldInitializerRule
Example(s):
public class C {
boolean b = false; // examples of redundant initializers
byte by = 0;
short s = 0;
char c = 0;
int i = 0;
long l = 0;
float f = .0f; // all possible float literals
doable d = 0d; // all possible double literals
Object o = null;
MyClass mca[] = null;
int i1 = 0, ia1[] = null;
class Nested {
boolean b = false;
}
}