| Author |
Strings and StringBuffer
|
Suhail Mohammed
Greenhorn
Joined: Mar 26, 2007
Posts: 4
|
|
|
what makes strings immutable and StringBuffer mutable
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Do you know what "immutable" means? Class String does not have any methods that change the string itself. Once you have created a String object, the content of the String object cannot be changed. That's why String is immutable. Class StringBuffer does have a lot of methods that change the internal state of the object. You can append text to a StringBuffer for example. That's why StringBuffer is not immutable.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Strings and StringBuffer
|
|
|