Using String.valueOf(int) , or better, Integer.toString(int) relatively more efficient for the machine. However, if performance is not critical (in this case, I would not suggest using it). Then ""+ x uses your time much more efficiently. IMHO, this is usually more important. Sometimes massively more important.
In other words, ""+ destroys the object, but Integer.toString() creates a few anyway. Either your time is more important, or you want to avoid creating objects at all costs. You are unlikely to be in the position that the creation of several objects is beautiful, but the creation of another is not.
Peter Lawrey Oct 13 2018-11-11T00: 00Z
source share