I was using IntelliJ to generate the hashCode()
function of a class for me. The hashCode
is depending only on one field of type long
. IntelliJ generated the following for me:
@Override
public int hashCode() {
return (int) (longField ^ (longField >>> 32));
}
Why is this a good implementation? Is it a good implementation after all?