在學習LinkedList的時候想過這個問題,猜想就是在內部實現的時候添加定義一個類,其中定義本類型的數據。
今天看到了源碼。和我想的差不多,很簡單。
private static class Entry<E> {
E element; // 當前存儲元素
Entry<E> next; // 下一個元素節點
Entry<E> previous; // 上一個元素節點
Entry(E element, Entry<E> next, Entry<E> previous) {
this.element = element;
this.next = next;
this.previous = previous;
}
}