packagejavaRadarLinkedList;
importjava.util.Collections;
importjava.util.Enumeration;
importjava.util.LinkedList;
public classEnumerationTraversal {
      public static void main(String[] args) {
            //create Linked List
            LinkedList<String> javaRadarList = newLinkedList<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());
            }
      }
}

Source link

Traverse linked list using enumeration

One thought on “Traverse linked list using enumeration

Leave a Reply

Your email address will not be published. Required fields are marked *