This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes String & String Buffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "String & String Buffer" Watch "String & String Buffer" New topic
Author

String & String Buffer

Jitendra Nehul
Greenhorn

Joined: Jan 01, 2001
Posts: 3
Hello Everybody,
What is the difference between String & String Buffer.
Muhammad Ali
Greenhorn

Joined: Dec 04, 2000
Posts: 28
String is an immutable class, i.e. the objects of this class once intialized can't change their values. In other words, there is no append method in the String class, etc.
StringBuffer on the other hand, allows various ways of manipulating, removing and inserting characters, etc.
Use String when you are sure that the characters are fix (e.g., a web page fetched from the Internet). Use StringBuffer when you have to manipulate the individual characters.
------------------
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Jitendra,
See, http://www.javaworld.com/javaworld/javaqa/2000-12/04-qa-1229-stringredux.html.
Hope this helps.
-Peter
 
Don't get me started about those stupid light bulbs.
 
subject: String & String Buffer
 
Similar Threads
what is difference in string and string buffer
Diff between string and string buffer
String Vs String Buffer
Searching hashmap for array String [] occurences?
how to trim a StringBuffer??!!