Estou com um pequeno problema na inclusão de minha árvore, quando eu adiciono numeros maiores, (ex. 111, 222, 333) ele não lista os maiores, mas quando pelo menos o segundo está menor ele aparece (ex. 3333, 2222, 1111). Alguém me ajuda por favor.
Segue o código:
public void inserir( Paciente p )
{
int cpf1, cpf2 = 0;
if( this.pri == null )
this.pri = p;
else
{
cpf1 = Integer.parseInt( p.getCpf() );
cpf2 = Integer.parseInt( pri.getCpf() ) ;
if( cpf1 > cpf2 )
{
if( this.dir != null )
this.dir.inserir( p );
else
{
this.dir = new arvore();
this.dir.inserir( p );
}
}
else
if( cpf1 < cpf2 )
{
if( this.esq != null )
this.esq.inserir( p );
else
{
this.esq = new arvore();
this.esq.inserir( p );
}
}
}
}