This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes reg: string and stringbuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reg: string and stringbuffer" Watch "reg: string and stringbuffer" New topic

reg: string and stringbuffer

sri charan

Joined: Dec 04, 2007
Posts: 14
Hello friends,

I just want to know if the "stringbuffer" is giving more flexibuility for data store then why in most case's we go for "string"

can any one please confirm this......
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37884
Don't use StringBuffer any more; use StringBuilder.

String is used because its objects are immutable, so they can be reused without using too much memory, or threading problems.

StringBuilder is used because it gives a fast way of altering the contents of String-like text.
I agree. Here's the link:
subject: reg: string and stringbuffer
Similar Threads
How many Object is created?
StringBuffer and String returned from a method doubt
StringBuffer question
byte [ ] to StringBuffer