Sometimes there is need to change an integer to text.I often use the following way: + myNumberBut there is alternative way:Integer.toString(myNumber)Which one is better (performance, readability, safety)? Or are those equal?
Which way is better for converting number to string?
java
I would recommendString.valueOf(myNumber)This allows you to to change myNumber to another primitive type - or a Number - later. + myNumbershould be avoided since :it produces clutter bytecode (instanciating a new StringBuffer)it does not convey what you wanted to do with myNumber