I\'m working on a project where all conversions from int
to String
are done like this:
int i = 5;
String strI = \"\" + i;
>
Personally, I don't see anything bad in this code.
It's pretty useful when you want to log an int value, and the logger just accepts a string. I would say such a conversion is convenient when you need to call a method accepting a String, but you have an int value.
As for the choice between Integer.toString
or String.valueOf
, it's all a matter of taste.
...And internally, the String.valueOf
calls the Integer.toString
method by the way. :)