I'm trying to write a method that removes all instances of a value from a singly linked list, but I'm having some trouble. I'm receiving a nullpointerexception on line 8 of this code:
public void remove (int value)
{
IntegerNode temp=head;
while (temp !=null)
{
if (temp.value == value)
{
temp.next = temp.next.next;
count--;
}
temp=temp.next;
}
}
Not certain what it is I'm doing that's bringing up this error...