ListIterator
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
public class ListIteratorTest {
public static void main(String[] args){
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
ListIterator<Integer> li = list.listIterator();
while (li.hasNext()){
System.out.println(li.next());
}
while (li.hasPrevious()){
System.out.println(li.previous());
}
}
}
OUTPUT:
1
2
3
3
2
1
No comments:
Post a Comment