Why is ""+ int flagged for Java in SonarQube -


in java can convert int string "" + intvalue. sonarqube , sonarlint flag inappropriate.

why inappropriate. far know integer.tostring(intvalue) more verbose , same.

i can imagine flag if not "" object x used in x + intvalue x initialized integer. ran javascript code.

with regards why it's bad, java automatically optimizes string concatenation use stringbuilder instead. means doing this

"" + d 

you're doing

new stringbuilder().append(d).tostring(); 

and if do

d + "" 

you end compiling

new stringbuilder(string.valueof(d)).tostring(); 

which pretty big waste of resources relative calling

string.valueof(d); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -