Skip to content

Instantly share code, notes, and snippets.

@dangnhdev
Last active March 8, 2016 15:48
Show Gist options
  • Save dangnhdev/24aee2f55c06b701ce9d to your computer and use it in GitHub Desktop.
Save dangnhdev/24aee2f55c06b701ce9d to your computer and use it in GitHub Desktop.
public class Person {
private int pid;
private String name;
public Person(int pid, String name) {
this.pid = pid;
this.name = name;
}
@Override
public boolean equals(Object obj){
if (obj == null || !(obj instanceof Person)) return false;
if (obj == this) return true;
Person p = (Person) obj;
return p.getName().equals(this.name);
}
public String getName() {
return name;
}
@Override
public int hashCode(){
return this.pid;
}
}
@dangnhdev
Copy link
Author

Added override annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment