I'm trying to remove the last node from a linkedList and return it. This is part of a Linkedlist class. The following method that I wrote doesn't delete the last node. Does anybody know why?
public int delete(){
if(front==null){
throw new NoSuchElementException();
}else{
ListNode current = front;
while(current.next!=null){
current = current.next;
}
int delete = current.data;
current = null;
return delete;
}
}