Solution:
Equals and hashcode methods are to be implemented In order to use any object as Key in HashMap, in Java.
Credit: 3870