posted 19 years ago
If you're doing lots of String I/O, moving values, etc. StringBuffer is more efficient.
Think of the situation where you have to compare or process 100,000 records of data. The object StringBuffer would immediately either go out of scope, or be reassigned a new variable reference. In either case, you're allowing for "cleaner" garbage collection.
The way I understand it, especially if you instantiate string outside of your loop, it could take the garbage collector longer to get to the String objects.
Hope this helps!
Marcus
Marcus L�ubli, SCJP 1.4, CLP 5.0, SCWCD 1.4 (preparing)