Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.List; import java.util.ListIterator; public class JavaListIteratorhasPreviousExample3 { public static void main(String[] args) { List
li = new ArrayList<>(); ListIterator
itr = null; li.add("Java"); li.add("is"); li.add("a"); li.add("platform"); li.add("independent"); li.add("language"); itr = li.listIterator(); System.out.println("The given string in actual order :"); while (itr.hasNext()) { System.out.println(itr.next()); } System.out.println("The given string in reverse order :"); while (itr.hasPrevious()) { System.out.println(""+itr.previous()); } } }
Output