abhimanyu081
11/12/2018 - 4:24 PM

EnumerationExample

EnumerationExample

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

public class EnumerationExample {

	public static void main(String[] args) {
		
        Vector<String> cityList = new Vector<String>();
        
		cityList.add("Delhi");
		cityList.add("Agra");
		cityList.add("Bangalore");
		cityList.add("Kerala");
		cityList.add("Pune");
  
        // At beginning cursor will point to index just before the first element in vector 
        Enumeration<String> enm = cityList.elements(); 
        while(enm.hasMoreElements()) {
        	String city = enm.nextElement();
        	System.out.println(city);
        }
	}
}