Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.List; import java.util.ListIterator; public class JavaListIteratorhasPreviousExample2 { public static void main(String[] args) { List
li = new ArrayList<>(); ListIterator
itr = null; li.add('N'); li.add('I'); li.add('T'); li.add('I'); li.add('N'); itr = li.listIterator(); System.out.println("In actual order :"); while (itr.hasNext()) { System.out.println(itr.next()); } System.out.println("In reverse order :"); while (itr.hasPrevious()) { System.out.println(""+itr.previous()); } } }
Output