Autoboxes only when there is an “impedance mismatch” between reference types and primitives
No.
If we look at the source code of valueOf
method with int
param
public static String More ...valueOf(int i) {
return Integer.toString(i, 10);
}
calling ToString on Integer wrapper
A new string creating there in Integer wrapper toString()
public static String More ...toString(int i, int radix) {
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
radix = 10;
/* Use the faster version */
if (radix == 10) {
return toString(i);
}
char buf[] = new char[33];
boolean negative = (i < 0);
int charPos = 32;
if (!negative) {
i = -i;
}
while (i <= -radix) {
buf[charPos--] = digits[-(i % radix)];
i = i / radix;
}
buf[charPos] = digits[-i];
if (negative) {
buf[--charPos] = '-';
}
return new String(buf, charPos, (33 - charPos));
}