Skip to content

Instantly share code, notes, and snippets.

@angeliski
Created January 3, 2019 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angeliski/358fbe8004e1c49b48761a6cde6e252e to your computer and use it in GitHub Desktop.
Save angeliski/358fbe8004e1c49b48761a6cde6e252e to your computer and use it in GitHub Desktop.
public class Pessoa {
String nome;
String sobrenome;
String idade;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((idade == null) ? 0 : idade.hashCode());
result = prime * result + ((nome == null) ? 0 : nome.hashCode());
result = prime * result
+ ((sobrenome == null) ? 0 : sobrenome.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pessoa other = (Pessoa) obj;
if (idade == null) {
if (other.idade != null)
return false;
} else if (!idade.equals(other.idade))
return false;
if (nome == null) {
if (other.nome != null)
return false;
} else if (!nome.equals(other.nome))
return false;
if (sobrenome == null) {
if (other.sobrenome != null)
return false;
} else if (!sobrenome.equals(other.sobrenome))
return false;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment