package
javaRadarLinkedList;
import
java.util.Iterator;
import
java.util.LinkedList;
public class ItrTraversal {
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
Iterator<String>
listIterator = javaRadarList.iterator();
System.out.println("Traversal
in forward direction");
while(listIterator.hasNext()){
System.out.println(listIterator.next());
}
}
}
OUTPUT:
Traversal in forward direction
Java
Jquery
Spring
Hibernate
EJB
No comments:
Post a Comment