遍历 List 的方法:
1. for
2. advanced for
3. Iterator
4. while
5. ListIterator List<E> list 1. for
for (int i = 0; i < list.size(); i++) {
E element = list.get(i);
} 2. advanced for
for (E element : list) { } 3. Iterator
for (Iterator<E> iter = list.iterator(); iter.hasNext(); ) {
E element = iter.next();
} 4. while
while (i < list.size()) {
E element = list.get(i);
i++;
} 5. ListIterator
for (ListIterator<E> iterator = list.listIterator(); iterator.hasNext(); ) {
E element = iterator.next();
}