1 / 9
Settings
<<<>>>
Now we will look at the remove method. Here is the linked list before we remove the node with value 8.
- public Object remove() {
- if (curr == tail) return null; // Nothing to remove
- Object it = curr.element(); // Remember value
- curr.prev().setNext(curr.next()); // Remove from list
- curr.next().setPrev(curr.prev());
- curr = curr.next();
- listSize--; // Decrement node count
- return it; // Return value removed
- }
null
23
8
35
null
head
curr
tail