Skip to content

Roy Tutorials

Technical… Theoretical… Practical…

  • Home
  • FAQs
  • About Me
  • Home
  • hashCode and equals method

Tag: hashCode and equals method

Introduction In this Java HashMap example I am going to tell you how to use custom object as a key in HashMap. In custom object as a key in HashMap example, I will show you how to work with user defined objects as keys in Map. To use user defined objects as keys in Map…

Leave a Comment on Custom Object as a Key in HashMap
Posted in Java

Custom Object as a Key in HashMap

Introduction Here in this example I am going to show you how to add unique objects in Java HashSet. Set interface in Java maintains uniqueness, so any duplicacy is not allowed in Set interface. The HashSet class maintains uniqueness through HashMap, so HashSet uses internally HashMap to determine unique elements. When you add String type…

Leave a Comment on How To Add Unique Objects In Java HashSet
Posted in Java

How To Add Unique Objects In Java HashSet

Introduction Here I will discuss how to override equals() and hashCode() methods in Java. In Java language the important contract is whenever you override one of the methods (equals() and hashCode()), then you must override the other method. So it means that when you override method equals() then you must override hashCode() or vice versa.

Leave a Comment on Override equals() and hashCode() Methods in Java
Posted in Java

Override equals() and hashCode() Methods in Java

Categories

Copyright © 2014 - 2022 Roy Tutorials

Privacy | Terms & Conditions