Program for vector in java.
Below is the program.
import java.util.*;
class vectorDemo
{
public static void main(String args[])
{
Vector v = new Vector(3,2);
System.out.println("Intial Size : " + v.size());
System.out.println("Intial Capacity : " + v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after 4 additions : " + v.capacity());
v.addElement(new Double(4.55));
System.out.println("Capacity after adding double element : " + v.capacity());
}
}
Below is the program.
import java.util.*;
class vectorDemo
{
public static void main(String args[])
{
Vector v = new Vector(3,2);
System.out.println("Intial Size : " + v.size());
System.out.println("Intial Capacity : " + v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after 4 additions : " + v.capacity());
v.addElement(new Double(4.55));
System.out.println("Capacity after adding double element : " + v.capacity());
}
}
No comments:
Post a Comment