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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -