Technical Discussion :: Java
Home > Technical Interview Q&A > Java > Discussion
1 / 66
Difference between StringBuffer and StringBuilder
Answer:
StringBuffer:
- StringBuffer is less efficient than StringBuilder.
- StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously.
StringBuilder:
- StringBuilder is more efficient than StringBuffer.
- StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously.
Asked In ::
Aditya Singh
13 Oct, 2019 1:07 PM
StringBuffer:
- StringBuffer is less efficient than StringBuilder.
- StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously.
StringBuilder:
- StringBuilder is more efficient than StringBuffer.
- StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously.