Last active
March 8, 2016 15:48
-
-
Save dangnhdev/24aee2f55c06b701ce9d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added override annotation