ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What is the main difference between a String and a StringBuffer class?

String is immutable : you can’t modify a string object but can replace it by creating a new instance. Creating a new instance is rather expensive.

 

StringBuffer is mutable : use StringBuffer or StringBuilder when you want to modify the contents. StringBuilder was added in Java 5 and it is identical in all respects to StringBuffer except that it is not synchronized,which makes it slightly faster at the cost of not being thread-safe.

Related Posts Plugin for WordPress, Blogger...
Flag Counter