Hello to all.
It bugs me something. Please help me figure out why exactly we override equals() and hashCode() methods. I read that we must override both methods because they are used by Hash collections.
For what I can understand, hashCode() is needed because in adding an element(in a hash collection) it adds it to a bucket based on hashCode() value (I read it somewhere that this is obj address maybe???), and equals() it use if we add some other obj, compares it to the other.
Frankly speaking, I don't know if I am mistaking and I am not 100% sure, why it needs both methods and when exactly it uses them.