• Register

Share:- Whatsapp Facebook Facebook

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

Categories

0 votes
1.5k views
What is difference between String, StringBuffer and StringBuilder?
in Java by
retagged

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.

by
...