May 4 in JAVA
Q: What are the differences between StringBuffer and StringBuilder?

1 Answer

0 votes
May 4

The differences between the StringBuffer and StringBuilder is given below.

No. StringBuffer

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

2) StringBuffer is less efficient than StringBuilder.

StringBuilder:

  1. StringBuilder is non-synchronized,i.e., not thread safe. It means two threads can call the methods of StringBuilder simultaneously.
  2. StringBuilder is more efficient than StringBuffer.

Related questions

0 votes
May 2 in JAVA
0 votes
Dec 16, 2020 in JAVA
...