Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class School {
private final String name;
private final String nickname;
public School(String name, String nickname) { = name;
this.nickname = nickname;
public int hashCode() {
return 1;
public boolean equals(Object obj) {
return (name.equals(((School) obj).name) || (nickname.equals(((School) obj).nickname)));

This comment has been minimized.

Copy link

@geoffreywiseman 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.


This comment has been minimized.

Copy link

@iamnoah 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.