This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes the capacity()  method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "the capacity()  method" Watch "the capacity()  method" New topic

the capacity() method

Khurram Ajmeri

Joined: Nov 24, 2001
Posts: 6
hello there
how does capacity() method in StringBuffer work?
Azam Bukhari
Ranch Hand

Joined: Oct 03, 2000
Posts: 58
The Capacity() method for the string buffer works as follows...
The default length of a String buffer object is 16 initially.
When we initialize this object with a string let be it like "Paki" then when u go & try out the length of this Buffer object u ll get 4 but when u go & try to find out the capacity() will return 16...
In other words its a tring with no limitation or boundaries

Don't wanna invent the wheel again!!
I agree. Here's the link:
subject: the capacity() method
Similar Threads
Size of String Buffer
ArrayList vs Vector Size and Capacity difference ?
StringBuffer capacity
StringBuffer doubt
StringBuffer size