Why should I override hashCode() when I override equals() method?
It works for you because your code does not use any functionality (HashMap, HashTable) which needs the hashCode() API. However, you don’t know whether your class (presumably not written as a one-off) will be later called in a code that does indeed use its objects as hash key, in which case things will be affected. … Read more