Untitled Document

Subscribe here to get updates on new Videos

 

5. Difference between StringBuffer and StringBuilder?

 

 

 

previous homenext

 

Differences Between StringBuffer and StringBuilder?

StringBuilder is exactly same as StringBuffer(Including Methods and Constructors) except the following differences

SringBuffer
StringBuilder
1. Every method present in StringBuffer is synchronized. 1.No method present in StringBuilder is synchronized.
2. At a time only one thread is allow to operate on StringBuffer object. Hence StringBuffer object is Thread safe. 2. At a time multiple threads are allow to operate on StringBuilder object and hence StringBuilder object is not Thread Safe.
3. It Increases waiting time of threads and hence relatively performance is low. 3. Threads are not required to wait to operate on StringBuilder object and hence relatively performance is high.
4. Introduced in 1.0 version. 4. Introduced in 1.5 Version.