• Register
Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

What is difference between String, StringBuffer and StringBuilder?

0 votes
1,491 views
What is difference between String, StringBuffer and StringBuilder?
asked Nov 20, 2013 in Java by piyush agrawal
retagged Nov 22, 2013

1 Answer

0 votes

There are following difference among String, StringBuilder and StringBuffer:

Mutability:

String is immutable, if you try to edit/modify their values then new object gets created always, whereas StringBuffer and StringBuilder are mutable so they can change their values.

Synchronised:
StringBuffer's all methods are synchronised, but StringBuilder's all methods are not synchronised.

Performance:
StringBuilder gives us better performance rather than StringBuffer. Because, synchronised having locs.

Thread-Safety:

Difference between StringBuffer and StringBuilder:
StringBuffer is thread-safe. StringBuilder is not thread-safe.

answered Nov 22, 2013 by Ajay Panwar
...