• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can somebody explain these lines of code?

 
Klaas Vredevort
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I don't understand the StringBuffer function in this file?
 
Joni Salonen
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic