Computer Science, asked by skjahirkhan, 1 year ago

what is the difference between string and stringbuffer

Attachments:

Answers

Answered by sorizasha
2
1)String class is immutable.
2)String is slow and consumes more memory when you concat too many strings because
every time it creates new instance.
3)String class overrides the equals() method of Object class. So you can compare the contents of two strings by equals() method.


spring buffer
StringBuffer class is mutable.
StringBuffer is fast and consumes less memory when you cancat strings.
StringBuffer class doesn't override the equals() method of Object class.
Similar questions