Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Effective Java snippets
@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