equals & hashCode.
Contracts of equals and hashCode
In Java, equals and hashCode must be consistent: equal objects must have the same hash code. Violating this breaks hash-based collections like HashSet or HashMap.
Anti-pattern: equals overridden without hashCode:
Correct: implement both equals and hashCode: