aspose file tools
The moose likes Beginning Java and the fly likes Strings and StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Strings and StringBuffer" Watch "Strings and StringBuffer" New topic
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
    
    3

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Strings and StringBuffer
 
Similar Threads
append AND concat
String vs StringBuffer
while loop
+ operator in String
Strings and StringBuffer