"" + i
new StringBuilder().append(i).toString();
,
Integer.toString(i)
2. 0,1 .
However, simplicity of the code is usually more important than performance, and the time it takes to write / verify / maintain a longer sequence of code usually costs more than a few loops that you could save.
eg. for example, iit becomes long. In the first case, you will not need to change the code, it will still be.
""+i
however, the second example should be changed wherever it is used to
Long.toString(i);
A small change, but which would probably be completely unnecessary.
source
share