Overriding only equals() method without overriding hashCode() causes the two equal instances to have unequal hash codes , which violates the hashCode contract (mentioned in Javadoc) that clearly says, if two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two …