So, I just looked for a while, all the different questions here are about .valueOfwith strings, but they all seem to relate to conversions. Comparing .valueOfonly with + "".
I want to know if it is worth it or should be used at all .valueOfif it is concatenation.
Example:
LOGGER.info("Final Score: " + String.valueOf(Math.round(finalScore * 100)) + "%");
VS
LOGGER.info("Final Score: " + Math.round(finalScore * 100) + "%");
It seems that use is String.valueOfnot required if you have the actual lines to go along with it. I understand that it is better to use .valueOfif you just convert it and intend to use an empty string.
source
share