package
javaRadarLinkedList;
import
java.util.Collections;
import
java.util.Enumeration;
import
java.util.LinkedList;
public class
EnumerationTraversal {
public static void main(String[] args) {
//create
Linked List
LinkedList<String>
javaRadarList = new
LinkedList<String>();
//Add elements
to LinkedList
javaRadarList.add("Java");
javaRadarList.add("Jquery");
javaRadarList.add("Spring");
javaRadarList.add("Hibernate");
javaRadarList.add("EJB");
//creating
iterator 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());
}
}
}
No comments:
Post a Comment