Maybe this question seems ridiculous for you, but I clearly do not understand (I am junior Java) why should we override equals()
and hashCode()
often together?
Indeed, I can override equals()
for some class to make a specific comparing, but why should I override hashCode()
too?
Thank you very much!