Technical Discussion :: Java
Home > Freshers > Technical Interview Questions > Java
14.
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 :: Aricent
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.