• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String Buffer & String

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,

I could remember there was some write up by Cindy on the above two.. could not able to locate on the site. Can somebody help me?

regards,
arun
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you'd have some luck using Cindy's member number as one of the search parameters. It's 3498.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Object type Comparision

String -->> immutable (Value once assigned cannot be modified)
StringBuffer -->> mutable (Value can be modified).

Performance comparision

Performance wise StringBuffer is better when u compare String with StringBuffer in string manipulation that is
ex:
String str = "Hello";
str = str+"World" ;
sop(str);

StringBuffer sbstr = new StringBuffer("Hello");
sbstr.append("world");
sop(sbstr.toString());

if we look at the above example the major and hidden difference is internally how JVM handles the string manipulation....

when we say str = str+"World";

internally ::

StringBuffer xxx = new StringBuffer(str);
xxx.append("World");
str = xxx.toString();

Now u can make out that internally there is a overhead of converting the String str to StringBuffer and applying append method on that and finally it is assigned backto the str the modifed str....


Cheers
satish
 
bronco
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More details here...

http://www.javaworld.com/javaworld/jw-03-2000/jw-0324-javaperf.html
 
She'll be back. I'm just gonna wait here. With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic