Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Beginner
Nov 13, 2017

WEBINAR: On-Demand

Unleash Your DevOps Strategy by Synchronizing Application and Database Changes REGISTER >

Converting Numbers to Strings

"" + set.size()
new Integer(set.size()).toString()

The return type of the Set.size() method is int, but it is desired a conversion to String. These two lines do the conversion, but the first use the penalty of a concatenation operation ((new StringBuilder().append(i).toString())) and the second one creates an intermediate Integer wrapper. So, the right way to convert numbers to Strings is:

Integer.toString(set.size())
Octavia Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date