Hello All,
I am having a problem with removing a specific item from a linked list. Any advice would be great:
Here are some snippets:
private Node head; //the head node at the front of the list
private Node previous; //element just before the current position
private Node current; //refers to the current element
public boolean removeSpecific(Item thing)
{
if(head != null)
{
if(previous == null)
head = head.next;
else if(current.data.equals(thing))
{
previous.next = current.next;
current = current.next;
count--;
return true;
}
}
return false;
}
Something is very off here.
Any assistance will be appreciated.
Thank you