package wrap;
import java.util.*;
public class ArrayListDemo {
public static void main(String [] args){
ArrayList<String> a=new ArrayList<String>();
a.add("B");
a.add("C");
a.add("D");
ListIterator<String> i=a.listIterator();
while(i.hasPrevious()){
System.out.println(i.previous());
}
}
}
The program works fine for hasNext() and next() methods but for hasPrevious() and previous() it displays a message as below::
<terminated> ArrayListDemo [Java Application] C:\Program Files (x86)\Java\jre7\bin\javaw.exe (28-Oct-2013 3:20:35 PM)