Wednesday, 9 September 2015

Java- Difference between StringBuffer and StringBuilder


StringBuffer
StringBuilder
1)      StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously.
StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously.

2)      StringBuffer is less efficient than StringBuilder.

StringBuilder is more efficient than StringBuffer.
3)      StringBuffer is slow
StringBuilder is fast



No comments:

Post a Comment