Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About String

 
Devi Priya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the exact difference between String and Stringbuffer class?
 
uday tiruveedula
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String is immutable where as StringBuffer is mutable. The significant performance difference between these two classes is that StringBuffer is faster than the String when performing simple concatenations.

More info can be obtained at
http://www.javaworld.com/javaworld/jw-03-2000/jw-0324-javaperf.html

or have a look at
http://www.precisejava.com/javaperf/j2se/StringAndStringBuffer.htm
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by uday kiran t v:
The significant performance difference between these two classes is that StringBuffer is faster than the String when performing simple concatenations.


More specifically, StringBuffer is faster for concatenations that cannot be done in a single expression, i.e. when it's done in a loop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic