I am working in Java code optimization. I\'m unclear about the difference between String.valueOf
or the +\"\"
sign:
int intVar = 1;
Even though answers here are correct in general, there's one point that is not mentioned.
"" + intVar
has better performance compared to String.valueOf()
or Integer.toString()
. So, if performance is critical, it's better to use empty string concatenation.
See this talk by Aleksey Shipilëv. Or these slides of the same talk (slide #24)