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 synchronised, which makes
0 Comments:
Post a Comment
<< Home