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
Post a Comment