File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC 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
It's not a secret anymore!