In the guidelines to write a good hashCode() written in Effective java, the author mentions the following step if the field is long.
If the field is a long, compute (int) (f ^ (f >>> 32)).
I am not able to get why this is done. Why are we doing this ?
In Java, a
longis 64-bit, and anintis 32-bit.So this is simply taking the upper 32 bits, and bitwise-XORing them with the lower 32 bits.