Friday, 26 July 2013

Example of Enumeration in java

import java.util.Enumeration;
import java.util.Vector;

/*
    Example of Enumaration with Vector
    @Author Manoj
*/

class MyEnumaration{
    public static void main(String str[]){
        Vector<String> vtr=new Vector<String>();
        vtr.add("Hi");
        vtr.add("Tester");
        vtr.add("How");
        vtr.add("Are");
        vtr.add("You?");
        Enumeration enumobj=vtr.elements();
        while(enumobj.hasMoreElements()){
        System.out.println(enumobj.nextElement());
           
        }
       
    }
}

OUTPUT:-


Hi
Tester
How
Are
You?


Read more about Enumeration.