Why both hashCode() and equals() exist
java
Solution
Why do you think one is redundant? They say different things:
- `hashCode` is "give me some way of efficiently seeing whether two objects are likely to be equal"
- `equals` is "check whether this object is genuinely equal to another"
You definitely need both - although I don't believe they should really be in Object in the first place.
You absolutely need hash codes in order to perform efficient lookups with hash tables - and you absolutely need further equality checks because hashes will collide (there are far more possible strings than hash codes, for example).
Problem
why java Object class has two methods hashcode() and equals()? One of them looks redundant and its percolated to the bottom most derived class?