aspose file tools
The moose likes Java in General and the fly likes String and StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "String and StringBuffer" Watch "String and StringBuffer" New topic
Author

String and StringBuffer

Zoram Paul
Ranch Hand

Joined: Jul 10, 2007
Posts: 59
Can anybody explain me when to use String and when the StringBuffer in an application? and Which one is better?


ZORAM<br />"If it's true that we are here to help others,<br />then what exactly are the others here for?"
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
StringBuffer has a performance advantage when you concatenate a lot of variable parts into one string. You can try some experiments on your target platform to see when "a lot" becomes worth the effort of using a StringBuffer.

StringBuffer is also mutable, meaning you can change it, while String is not.

Look through the doc and compare methods. What can one do that the other cannot?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String and StringBuffer
 
Similar Threads
StringBuffer
Again String.
stringBuffer VS string
byte [ ] to StringBuffer
Question on Garbage Collection