"Boxing" is the process of putting a primitive value into a primitive-wrapper object. When that's done purely to use the wrapper class' ``++toString++`` method, it's a waste of memory and cycles because those methods are ``++static++``, and can therefore be used without a class instance. Similarly, using the ``++static++`` method ``++valueOf++`` in the primitive-wrapper classes with a non-``++String++`` argument should be avoided.


== Noncompliant Code Example

----
int myInt = 4;
String myIntString = (new Integer(myInt)).toString(); // Noncompliant; creates & discards an Integer object
myIntString = Integer.valueOf(myInt).toString(); // Noncompliant
----


== Compliant Solution

----
int myInt = 4;
String myIntString = Integer.toString(myInt);
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
