String valueOf vs concatenation with empty string

后端 未结 10 1689
说谎
说谎 2020-11-27 05:05

I am working in Java code optimization. I\'m unclear about the difference between String.valueOf or the +\"\" sign:

int intVar = 1;         


        
10条回答
  •  暖寄归人
    2020-11-27 05:58

    I'd prefer valueOf(), because I think it's more readable and explicit.

    Any concerns about performance are micro-optimizations that wouldn't be measurable. I wouldn't worry about them until I could take a measurement and see that they made a difference.

提交回复
热议问题