afaik,

string is immutable and string buffer is mutable.
when we concatenate characters with string new string object will be created.
but when we append string buffer it remains the same object.

apart from these what are the key and other difference between them?.

P.S. unless the spot where you're using a StringBuffer is "thread" sensitive, use a StringBuilder rather than a StringBuffer. A StringBuffer is "synchronized" whereas a StringBuilder is not, making a StringBuilder more performant when synchronization is not an issue.

string is a final class
whereas stringbuffer is not

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.