This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String & String Buffer  RSS feed

 
Jitendra Nehul
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,
What is the difference between String & String Buffer.
 
Muhammad Ali
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jitendra,
See, http://www.javaworld.com/javaworld/javaqa/2000-12/04-qa-1229-stringredux.html.
Hope this helps.
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!