This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regarding StringBuffers and StringBuilders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regarding StringBuffers and StringBuilders" Watch "Regarding StringBuffers and StringBuilders" New topic
Author

Regarding StringBuffers and StringBuilders

praveen raaj
Greenhorn

Joined: Nov 30, 2009
Posts: 11
Hi Friends,
can you explain to me what is the common use for StringBuffers and StringBuilders?
Patel Chintan
Ranch Hand

Joined: Mar 01, 2007
Posts: 80
Hi,

The only difference between StringBuffer and StringBuilder is that StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer.

Chintan Patel, SCJP1.5, http://datewithjava.blogspot.com
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
StringBuffer and StringBuilder classes are both used to create mutable string objects which is not possible with String class the only difference between the two is already stated by chintan.


SCJP 1.6 96%
Afzal Rehman
Ranch Hand

Joined: Dec 16, 2009
Posts: 39
StringBuffer is syncronized
StringBuilder is unsyncronized.
StringBuffer and StringBuilder are mutable.
StringBuilder was added in java 5 API it's same as StringBuffer except is not thread safe
StringBuilder is faster then StringBuffer as performance point of view.


SCJP 6.0
Phungsuk Wangdu
Ranch Hand

Joined: Nov 04, 2009
Posts: 114
well common use could be if we want mutable string objects
and both are used as an alternative to stiring
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding StringBuffers and StringBuilders
 
Similar Threads
Converting an decimal int to a hex without using Integer.toHexString
Synchronizing Block code
Reversing String Not Working...
The Difference Between StringBuffer & StringBuilder
StringBuffer & StringBuilder and equals()