Java

Java

Made by DeepSource

Boolean constructor is inefficient, consider using Boolean.valueOf instead JAVA-P0066

Performance
Major

Creating new instances of java.lang.Boolean wastes memory, since Boolean objects are immutable and there are only two useful values of this type.

Bad Practice

Boolean a = new Boolean(true);

Recommended

Use the Boolean.valueOf method (or autoboxing since Java 1.5) to create Boolean objects instead.

Boolean a = true;

// or

Boolean b = Boolean.valueOf(true);

Note - This issue will be ignored within tests.

References