LinkedList基於雙向鏈表實現的java
private static class Node<E> { E item; Node<E> next; Node<E> prev; }
每一個鏈表存儲了 first 和 last 指針:數組
transient Node<E> first; transient Node<E> last;
Vector:指針
public synchronized boolean add(E e) { modCount++; ensureCapacityHelper(elementCount + 1); elementData[elementCount++] = e; return true; } public synchronized E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return elementData(index); }
ArrayList與LinkedList、Vector的區別:code