Java examples for Collection Framework:ListIterator
Iterate through elements Java using ListIterator
import java.util.Vector; import java.util.ListIterator; public class Main { public static void main(String[] args) { Vector v = new Vector(); /*from w w w.ja va 2s . co m*/ v.add("1"); v.add("2"); v.add("3"); v.add("4"); v.add("5"); ListIterator itr = v.listIterator(); System.out.println("Iterating through Vector elements in forward direction..."); while(itr.hasNext()) System.out.println(itr.next()); System.out.println("Iterating through Vector elements in backward direction..."); while(itr.hasPrevious()) System.out.println(itr.previous()); } }