Hashcode, equals and toString

equals

JDK

public final boolean equals(final Object obj) {
   if (this == obj) {
      return true;
   }

   if (obj == null) {
      return false;
   }

   if (getClass() != obj.getClass()) {
      return false;
   }

   final Employee other = (Employee) obj;
   return Objects.equals(id, other.id)
         && Objects.equals(name, other.name);
}

Apache Commons

hashCode

JDK

Apache Commons

toString

JDK

Guava

Apache Commons

Last updated

Was this helpful?