I'm not understanding a simple comparison I'm making, but it's not running as I think it should.
Situation
I ask the user to enter the name of the person, and capture with String nome = scan.next();
And sending to this function:
// FIND PESSOA
private boolean findPessoaInList(String nome){
Boolean _return = false;
for(Pessoa p : this.pessoas){
if(p.getNome() == nome){
_return = true;
// return true;
}
}
return _return;
}
To check if the person is already registered.
However, it never falls within if
even if the name already exists in the list.
Code getNome
in Pessoa
public String getNome() {
return nome;
}
If someone can explain to me what's happening, thank you.