I'm implementing a threaded list in Java. However, the remove function is causing me some problems, but specifically the remove part in the middle of the list. My list consists only of an integer field with a note.
public void remove(int nota)
{
Aluno ante = null;
Aluno posi = this.first;
while(posi.getNota() != nota)
{
ante = posi;
posi = posi.getProximo();
}
if(posi == null)
{
System.out.println("Valor não encontrado");
return;
}
if(posi == this.first)
{
this.first = posi.getProximo();
posi = null;
}
else if(posi.getProximo() == null)
{
ante.setProximo(null);
posi = null;
}
else
{
ante.setProximo(posi);
posi = null;
}
this.tamLista--;
}
Where is the error? I can not identify.