I saw that interface java.util.Map.Entry has methods:
boolean equals(Object o);
int hashCode();
Why are above methods a part of Entry interface when same methods are inherited from the Object class?
Thanks and Regards, Rahul
As the overriding defintion says; It is used when a class that extends from another class wants to use most of the feature of the parent class and wants to implement specific functionality in certain cases. And the oracle documentation for boolean equals() says;
This ensures that the equals method works properly across different implementations of the Map.Entry interface.
So for the specific implementation of equals() method the boolean equals(Object o) and int hashCode() are overridden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With