package Devmanuals.com; import java.util.List; import java.util.LinkedList; import java.util.ListIterator; public class ListIteratorNext { public static void main(String[] args) { LinkedList llist = new LinkedList(); llist.add("1"); llist.add("2"); llist.add("3"); llist.add("4"); llist.add("5"); System.out.println("Elements of list = " + llist); System.out.println("Size of list = " + llist.size()); ListIterator litr = llist.listIterator(); System.out.println("List has elements : " + litr.next()); System.out.println("List has elements : " + litr.next()); System.out.println("List has elements : " + litr.next()); System.out.println("List has elements : " + litr.next()); System.out.println("List has elements : " + litr.next()); // For next line the next( ) method will throws exception System.out.println("List has elements : " + litr.next()); } }