package Devmanuals.com; import java.util.*; import java.util.ListIterator; public class LISTListIteratorIndex { public static void main(String args[]){ LinkedList ll = new LinkedList (); ll.add("Ramesh"); ll.add("Shyam prasad"); ll.add("Hare ram"); ll.add("Rohan"); ll.add("Mohit"); System.out.println("List is : "+ll); ListIterator li = ll.listIterator(3); System.out.println("Is list has element before the position 3 : "+li.hasPrevious()); System.out.println("//Element in reverse order : "); while (li.hasPrevious()){ System.out.println(li.previous()); } ListIterator li1 = ll.listIterator(3); System.out.println("Is list contains element after the position 3 : "+li1.hasNext()); System.out.println("//Element in forward order : "); while (li1.hasNext()){ System.out.println(li1.next()); } ListIterator li2 = ll.listIterator(0); while (li2.hasNext()){ String s=(String)li2.next(); if(s.equals("Shyam prasad")) li2.set("Shyam"); } System.out.println("After replace name in old list then new list is : "+ll); ListIterator li3 = ll.listIterator(0); while (li3.hasNext()){ String s=(String)li3.next(); if(s.equals("Hare ram")) li3.remove(); } System.out.println("After removing name in old list then new list is : "+ll); } }