Which approach is better and why ?
If I write
cmissValue = String.valueOf(callDBDatasource.cMiss());
or
cmissValue = "" + callDBDatasource.cMiss();
What should be the approach?
"" + callDBDatasource.cMiss();
Will compile to:
new StringBuilder().append("").append(callDBDatasource.cMiss()).toString();
This will create a new object and is therefore significantly slower. See this question: Is string concatenaion really that slow?
This will be useful here (section "Converting numbers to Strings"): http://www.odi.ch/prog/design/newbies.php
Shortly:
String.valueOf(callDBDatasource.cMiss());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With