esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

What is the difference between the StringBuffer's capacity() and length()?
The StringBuffer has internally an array of characters in which it keeps the values of the characters. Each time you try to add more characters than this array's length, a new, bigger array must be created and the characters must be copied into it. StringBuffer.length() returns the length of string you have stored into the StringBuffer, the value you would normally expect. StringBuffer.capacity() returns the size of that internal array, which means how many characters can that StringBuffer keep without having to allocate a new, bigger array.


Further Information
Author of answer: Alexander Maryanovsky

Comments
Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.