File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between the StringBuilder and StringBuffer class" Watch "Difference between the StringBuilder and StringBuffer class" New topic
Author

Difference between the StringBuilder and StringBuffer class

akshitha Akki
Greenhorn

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 .

-hth


OCA7
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

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: http://aspose.com/file-tools
 
subject: Difference between the StringBuilder and StringBuffer class