Hint 1
Since the value 3 was not deleted fro the list, the bug must be in method remove
. Add a breakpoint
at the first line of this method (where current
front. It points to a node storing instance variable element
of value 1;
this node points to another node storing value 2, and so on.
Repeatedly click on "step over" or press F6 until the condition of the if
statement inside the
while
loop is true. at this point variable current
is pointing to the node storing
the value 3 (check this in the "Variables" window of the debugger). Press F6 once again until the break
statement is highlighted. At this point the value 3 must have been removed from the list. Check if this is the case:
look at the value of variable front
in the "Variables" window and follow the pointers of the nodes
in the list referenced by front
; is the node storing the value 3 still in the list?