// Vector Class Example
import java.util.*;
public class VectorDemo
{
public static void main(String[] args)
{
Vector v = new Vector();
int i = 10;
Integer j = new Integer(20);
String s = "Welcome";
v.add(i);
v.add(j);
v.add(s);
System.out.println("the elements of vector: " + v);
System.out.println("The size of vector are: " + v.size());
System.out.println("The elements at position 2 is: " + v.elementAt(2));
System.out.println("The first element of vector is: " + v.firstElement());
System.out.println("The last element of vector is: " + v.lastElement());
v.removeElementAt(2);
Enumeration e=v.elements();
System.out.println("The elements of vector: " + v);
while(e.hasMoreElements())
{
System.out.println("The elements are: " + e.nextElement());
}
}
}
No comments:
Post a Comment