hashCode() :
If you only override the hash-code method nothing will happen. Becausehappens, because it always returnreturns a new hashCode for each object asas an Object class.
equals() :
If you only override equalthe equals method, if a.equals(b) is true it means the hashCode of a and b must be the same but that does not happen. Because since you did not override the hashCode method.
Note : hashCode() method of Object class always returnreturns a new hashCode for each object.
So when you need to use your object in the hashing based collection, you must override both equals() and hashCode().