Vector class capacity()method example
Returns the current capacity of this vector.
Vector class capacity()method example. This example shows you how to use capacity()method.This method Returns the current capacity of this vector.
Here is the code:-
/*
* @Program that Returns the current capacity of this vector.
* Capacity.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class Capacity {
public static void main(String[] args) {
//creating vector
Vector v= new Vector();
v.add("girish");
v.add("tewari");
//creating enumeration interface
Enumeration E=v.elements();
System.out.println("Element added in the vector are: ");
while(E.hasMoreElements())
{
System.out.println(E.nextElement()+"\t");
}
//Returns the current capacity of this vector.
int i=v.capacity();
System.out.println("Capacity of the vector is: "+i);
}
} |
Output of the program:-
Element added in the vector are:
girish
tewari
Capacity of the vector is: 10 |
|