Java Reference
In-Depth Information
676
According to the definition of the remove method, it is illegal to call remove twice
in a row. Therefore, the remove method sets the previous reference to
position .
private class LinkedListIterator
implements ListIterator
{
. . .
public void remove()
{
if (previous == position)
throw new IllegalStateException();
if (position == first)
{
removeFirst();
}
else
{
previous.next = position.next;
}
position = previous;
}
. . .
}
Figure 7
Adding a Node to the Middle of a Linked List
Search WWH ::




Custom Search