Effective java hashcode implementation

Posted by Scobal on Stack Overflow See other posts from Stack Overflow or by Scobal
Published on 2010-05-13T14:32:54Z Indexed on 2010/05/13 14:34 UTC
Read the original article Hit count: 371

Filed under:
|

I was wondering if someone could explain in detail what

(int)(l ^ (l >>> 32));

does in the following hashcode implementation (generated by eclipse, but the same as Effective Java):

private int i;
private char c; 
private boolean b;
private short s;
private long l;
private double d;
private float f;

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + i;
    result = prime * result + s;
    result = prime * result + (b ? 1231 : 1237);
    result = prime * result + c;
    long t = Double.doubleToLongBits(d);
    result = prime * result + (int) (t ^ (t >>> 32));
    result = prime * result + Float.floatToIntBits(f);
    result = prime * result + (int) (l ^ (l >>> 32));
    return result;
}

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about hashcode