Search code examples
javaautoboxingstring-interning

Is converting int to a String counted as Autoboxing?


AFAIK When Java automatically converts a primitive type into wrapper class object than its called autoboxing because primitive is boxed into wrapper class.

So is

int test = 3;
String str = String.valueOf(test);

counted as autoboxing?

Reason to ask?

I recently came across this question. Reason for which I think is autoboxing which was introduced in java 5(not present in Java 4).


Solution

  • No. Autoboxing only applies to primitives -> wrappers. Since there is no String primitive (or wrapper), String has nothing to do with autoboxing.