Why is this an issue?
Creating temporary primitive wrapper objects only for String
conversion or the use of the compareTo
method is
inefficient.
Instead, the static toString
or compare
method of the primitive wrapper class should be used.
Noncompliant code example
new Integer(myInteger).toString(); // Noncompliant
Integer.valueOf(myInt).compareTo(0); // Noncompliant
Compliant solution
Integer.toString(myInteger); // Compliant
Integer.compare(myInteger, 0); // Compliant