Always Override hashCode When Overriding equals
When overriding the equals method in a class, you must also override the hashCode method. Failing to do so violates the general contract for hashCode, causing the class to malfunction in hash-based collections like HashMap and HashSet. The contract, derived from the Object specification, states: Rep...