package Devmanuals.com; import java.util.List; import java.util.LinkedList; import java.util.ListIterator; public class ListIteratorPrevious { public static void main(String[] args) { LinkedList llist = new LinkedList(); llist.add("A"); llist.add("B"); llist.add("C"); llist.add("D"); llist.add("E"); System.out.println("Elements of list = " + llist); System.out.println("Size of list = " + llist.size()); ListIterator litr = llist.listIterator(); while(litr.hasNext()) litr.next(); System.out.println("Elements in reverse order : "); System.out.println(litr.previous()); System.out.println(litr.previous()); System.out.println(litr.previous()); System.out.println(litr.previous()); System.out.println(litr.previous()); // For next line the previous( ) method will throws exception System.out.println("\t-------------THROWS EXCEPTION------------- "); System.out.println(litr.previous()); } }