Take a look at the source code for the JRE and you will probably see the difference. Or not. In fact, Strinv.valueOf (int foo) is implemented as follows:
public static String valueOf(int i) { return Integer.toString(i, 10); }
and Integer.toString (int foo, int radix)
public static String toString(int i, int radix) { ... if (radix == 10) { return toString(i); } ... }
This means that if you are using radix 10, you are best off calling Integer.toString (int foo). For other cases, use Integer.toString (int foo, int radix).
The concatenated solution first converts the int value to a string and then concatenates with the empty string. This is obviously the most expensive case.
paweloque Mar 17 '09 at 12:28 2009-03-17 12:28
source share