How hashCode () and equals () method are used in HashMap?

In HashMap, hashCode() is used to calculate the bucket and therefore calculate the index. equals method is used to check that 2 objects are equal or not . This method is provided by Object class. You can override this in your class to provide your own implementation.

Sizin İçin Seçtik  Do all objects have an equals () method?

Leave a Reply

Your email address will not be published. Required fields are marked *