Iterator:遍历
package com.geekbang.MyList;
import java.awt.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.jar.Attributes.Name;
public class MyArrayList {
public static void main(String[] args) {
ArrayList<String> arrayList = new ArrayList();
arrayList.add("A");
arrayList.add("B");
arrayList.add("C");
arrayList.add("D");
arrayList.add("E");
ListIterator<String> itrIterator = arrayList.listIterator();
while(itrIterator.hasNext()) {
System.out.println(itrIterator.next());
}
System.out.println("-------------------------");
while(itrIterator.hasPrevious()) {
System.out.println(itrIterator.previous());
}
}
}