This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths 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 Head First Android 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.
 
 
subject: Can somebody explain these lines of code?
 
It's not a secret anymore!