Primitive wrappers should not be instantiated only for "toString" or "compareTo" calls (squid:S1158)

Primitive wrappers should not be instantiated only for "toString" or "compareTo" calls (squid:S1158)

here we are creating an object of the wrapper class to use the method toString or to compare instead what we can do, we can directly use the static methods toString and do the conversion

Noncompliant Code Example

new Integer(myInteger).toString();  // Noncompliant

Compliant Code

Integer.toString(myInteger);        // Compliant

in the above compliant code we can see that we are directly calling the static method such as toString to convert primitive value to String instead of creating a object of the wrapper classes.