我遇到的另一个问题是,在我的Node Class中,当我没有它时可以继续前进。让我们更新为
private class Node{ private E data; private Node next; private Node prev; public Node(E data, Node next, Node prev) { this.data = data; this.next = next; this.prev = prev; }}现在,我的getMethod()将如下所示:
@SuppressWarnings("unchecked")public E get(int index){ if(index < 0) { throw new IndexOutOfBoundsException(); } if(index > size) { throw new IndexOutOfBoundsException(); } Node current = first; for (int i = 0; i < index; i++) { current = current.next; } return current.data;}


