1

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?

cimnine
  • 3,987
  • 4
  • 33
  • 49
  • 1
    Effective Java 2nd edition (http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683) have a great section about it. – Marco Acierno Apr 18 '14 at 11:02

0 Answers0