Created
February 14, 2013 10:04
-
-
Save snellm/4951711 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 School { | |
private final String name; | |
private final String nickname; | |
public School(String name, String nickname) { | |
this.name = name; | |
this.nickname = nickname; | |
} | |
@Override | |
public int hashCode() { | |
return 1; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
return (name.equals(((School) obj).name) || (nickname.equals(((School) obj).nickname))); | |
} | |
} |
return this.class.hashCode();
would be more efficient in heterogenous collections.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You wrote:
Reproducing that here because I'd forgotten by the time I read the code.