2
I have this function to delete from the list chained by value:
public void deletar(Object valor) {
Node temp = head;
while(temp != null) {
if(temp.getNext().getValor().equals(valor)) {
temp.setNext(temp.getNext().getNext());
break;
} else {
temp = temp.getNext();
}
}
}
But the last element always causes NullPointerException
, do not delete, how do I solve this?