package
javaRadarArrayList;
import
java.util.ArrayList;
import
java.util.Collections;
import
java.util.Enumeration;
import java.util.ListIterator;
public class
EnumerationTraversal {
public static void main(String[] args) {
//create Array
List
ArrayList<String>
javaRadarList = new
ArrayList<String>();
//Add elements
to ArrayList
javaRadarList.add("Java");
javaRadarList.add("Jquery");
javaRadarList.add("Spring");
javaRadarList.add("Hibernate");
javaRadarList.add("EJB");
//creating
enumeration to traverse over javaRadarList
Enumeration<String>
listEnumerator = Collections.enumeration(javaRadarList);
System.out.println("List
traversal using Enumeration");
while(listEnumerator.hasMoreElements()){
System.out.println(listEnumerator.nextElement());
}
}
}
OUTPUT:
List traversal using Enumeration
Java
Jquery
Spring
Hibernate
EJB
No comments:
Post a Comment