我想寫一個方法,從一個單獨的鏈表中刪除一個值的所有實例,但我遇到了一些麻煩。我收到這個代碼的第8行一個NullPointerException:它是單鏈接列表nullpointerexception
public void remove (int value)
{
IntegerNode temp=head;
while (temp !=null)
{
if (temp.value == value)
{
temp.next = temp.next.next;
count--;
}
temp=temp.next;
}
}
不能肯定我在做什麼是咯出這個錯誤...