File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Difference between the StringBuilder and StringBuffer class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between the StringBuilder and StringBuffer class" Watch "Difference between the StringBuilder and StringBuffer class" New topic

Difference between the StringBuilder and StringBuffer class

akshitha Akki

Joined: Aug 03, 2012
Posts: 24
The difference seem to be StringBuilder being non-synchrinized and StringBuffer being synchronized. But I am not getting a clear idea on how it works.Can I please get a simple example to start getting the concept correct?
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

Methods of StringBuffer class are synchronized although StringBuilder's not,hence faster performance.I don't care, how synchronization work for them.If you want to know, then read this Synchronized Methods .


Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Yeah, I suppose that's the difference.

This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.
Source: StringBuilder

The quieter you are, the more you are able to hear.
I agree. Here's the link:
subject: Difference between the StringBuilder and StringBuffer class
Similar Threads
String, StringBuilder, StringBuffer differences....
wat's d diff b/w string buffer and string builder
AbstractStringBuilder in jdk1.5
Conversion String concordinate (using +) to StingBuffer Class are no longer needed in Java 1.5
concatenation differance?