Created
October 4, 2015 11:01
-
-
Save Marchuck/a1e59cd435d8c683f8ec to your computer and use it in GitHub Desktop.
Effective Java snippets
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
@Override | |
public int hashCode(){ | |
int result = 17; | |
result = 31 * result + someBoolean ? 1:0; | |
result = 31 * result + someByte; | |
result = 31 * result + someChar; | |
result = 31 * result + someShort; | |
result = 31 * result + someInt; | |
result = 31 * result + someLong ^ someLong >>> 32 ; | |
result = 31 * result + Float.floatToIntBits(someFloat); | |
long doubles = Double.doubleToLongBits(someFloat); | |
result = 31 * result + doubles ^ doubles >>> 32; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment