Last active
March 30, 2017 04:16
-
-
Save linnykoleh/61714af2b740b4bd7599d880226d8061 to your computer and use it in GitHub Desktop.
This file contains 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 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