Created
January 3, 2019 23:22
-
-
Save angeliski/358fbe8004e1c49b48761a6cde6e252e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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