Java Vector capacity() Method
The capacity() method of Java Vector class is used to get the current capacity of the vector which is in use.
Following is the declaration of capacity() method:
This method does not accept any parameter.
This method returns the current capacity of the vector which is in use.
Java 1.2 and above
Example 1:Test it Now
Current capacity of Vector is: 5
Example 2:Test it Now
Elements of Vector are: [A, B, C] Current capacity of Vector: 3 Elements after addition: [A, B, C, JavaTpoint] Current capacity of Vector after modification: 6
Example 3:Test it Now
Default capacity of Vector: 10