1. private class ListItr implements ListIterator<E> {
    2. private Node<E> lastReturned;
    3. private Node<E> next; 当前节点
    4. private int nextIndex; 当前index
    5. private int expectedModCount = modCount;
    6. ListItr(int index) {
    7. // assert isPositionIndex(index);
    8. next = (index == size) ? null : node(index);
    9. nextIndex = index;
    10. }
    11. public boolean hasNext() {
    12. return nextIndex < size;
    13. }
    14. public E next() {
    15. checkForComodification();
    16. if (!hasNext())
    17. throw new NoSuchElementException();
    18. lastReturned = next;
    19. next = next.next;
    20. nextIndex++;
    21. return lastReturned.item;
    22. }