概述
java-list.png
ArrayList底层数据是数组, LinkedList的数据结构是双向链表, 节点数据结构如下:
private static class Node<E> {
E item;
Node<E> next;
Node<E> prev;
Node(Node<E> prev, E element, Node<E> next) {
this.item = element;
this.next = next;
this.prev = prev;
}
}
迭代器
List有迭代器ListIterator, 相比与Iterator, 其可以双向遍历,既可以向前遍历也可以向后遍历.
其方法如下:
ListIterator.png