aspose file tools*
The moose likes Beginning Java and the fly likes String Vs StringBuffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Vs StringBuffer" Watch "String Vs StringBuffer" New topic
Author

String Vs StringBuffer

Reggie McDougal
Ranch Hand

Joined: Sep 27, 2004
Posts: 69
If creating a string with lots of data should I use a stringBuffre instead of the following...



Is there a better way of doing this if sh can some one give me some example code.

Reg


You can never drink too much
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Your one line concatenations work fine as a String.

StringBuffer has the edge where you are building up a String out of many pieces, perhaps in a loop.


Mike Gershman
SCJP 1.4, SCWCD in process
Sanjaya Sugiarto
Ranch Hand

Joined: Mar 25, 2004
Posts: 229
And StringBuffer has a big performance benefit too.


<a href="http://www.wi.hs-furtwangen.de" target="_blank" rel="nofollow">Business Information Technology - Hochschule Furtwangen University, Germany</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Vs StringBuffer
 
Similar Threads
convert C++ to java??
Vending Machine Program - Not giving correct change. Need help desperatly!
Vending Machine Program - Not giving correct change. Need help desperatly!
Having trouble with executeBatch
Multiple preparedStatements 1 Connection