Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)));
}
}
@geoffreywiseman

This comment has been minimized.

Copy link

geoffreywiseman commented Feb 14, 2013

You wrote:

Null safety and typechecking ommitted for clarity

Reproducing that here because I'd forgotten by the time I read the code.

@iamnoah

This comment has been minimized.

Copy link

iamnoah commented Feb 14, 2013

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 can’t perform that action at this time.