Hashcode and Equals for Hashset [duplicate]

  1. There’s no need to call equals if hashCode differs.
  2. There’s no need to call hashCode if (obj1 == obj2).
  3. There’s no need for hashCode and/or equals just to iterate – you’re not comparing objects
  4. When needed to distinguish in between objects.

Leave a Comment