Skip to content

Instantly share code, notes, and snippets.

@linnykoleh
Last active March 30, 2017 04:16
Show Gist options
  • Save linnykoleh/61714af2b740b4bd7599d880226d8061 to your computer and use it in GitHub Desktop.
Save linnykoleh/61714af2b740b4bd7599d880226d8061 to your computer and use it in GitHub Desktop.
public class BadKey {
private String a;
private String b;
public BadKey(String a, String b) {
this.a = a;
this.b = b;
}
/** Bad equals and hashcode in order to obtain a collision*/
@Override
public int hashCode() {
return (a + b).length();
}
@Override
public boolean equals(Object obj) {
return a.length() == b.length();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment