Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.ListIterator; public class JavaListIteratorpreviousIndexExample2 { public static void main(String[] args) { ArrayList < Long > number = new ArrayList < Long > (); number.add(34l); number.add(78l); number.add(57l); ListIterator < Long > listIterator = number.listIterator(); System.out.println("The numbers are listed as : "+number); System.out.println("The Previous Index is : " + listIterator.previousIndex()); listIterator.next(); System.out.println("The Previous Index is : " + listIterator.previousIndex()); listIterator.next(); System.out.println("The Next Index is : " + listIterator.previousIndex()); } }
Output