Page: Difference Between String and StringBuffer in Java
0

Following are the differences between Java String and StringBuffer.

Java String

(1) Java string object is immutable i.e you can't change the value of string after it created.

(2) The performance of string is slow because it creates a new instance every time when we concat a string.

(3) String class overrides the equals() method of Object class.

Java StringBuffer

(1) Java StringBuffer is mutable i.e after creating StringBuffer you can change the value of StringBuffer.

(2) The performance of StringBuffer is fast.

(3) StringBuffer class does not override the equals() method of Object class.

ADD COMMENTlink
modified 21 months ago by gravatar for Yashbeer Yashbeer160 written 21 months ago by gravatar for anuragsingh07378 anuragsingh0737830
Please log in to add an answer.