Example of Vector in java

We write a program which is example of Vector.



package com.javaforecast4u;
import java.util.*;
public class ExampleVector {

    /**
     * @author: arbind
     */
    public static void main(String[] args) {
         Vector vect=new Vector();
         System.out.println(vect);
         System.out.println(vect.capacity());
         System.out.println(vect.size());

         vect.addElement("Java");
         vect.addElement("Fore");
         vect.addElement("Cast");
         vect.addElement(new Integer(100));
         System.out.println(vect);

         System.out.println("using Enumerator");
         Enumeration e=vect.elements();
         while(e.hasMoreElements())
         {
         Object o=e.nextElement();
         String str=o.toString();
         System.out.println(str);
         }

    }

}

0 comments :

Post a Comment