This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can somebody explain these lines of code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can somebody explain these lines of code?" Watch "Can somebody explain these lines of code?" New topic
Author

Can somebody explain these lines of code?

Klaas Vredevort
Greenhorn

Joined: Dec 27, 2005
Posts: 29


I don't understand the StringBuffer function in this file?
Joni Salonen
Ranch Hand

Joined: Jan 07, 2006
Posts: 53
It creates an empty StringBuffer in which you can put at least 128 characters, without needing to allocate more memory. If you add more than 128 characters it will have to allocate a new, larger internal character buffer.

You are given the option to specify the initial size because in a very tight loop reallocation may degrade performance. Which means that in 99% of the cases you don't need to do it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can somebody explain these lines of code?
 
Similar Threads
Adding nulls to stringbuffers
Adding a usedChar array in my program
Please explain this line of code to me
a simple question
Can somebody show me how to implement buttons?