1.

What Do You Understand By Hashcode () And Equals () Methods?

Answer»

A HashMap is used for key object where as hashCode() and equals() METHOD to CONSIDER the INDEX to out the key value pair. The hashCode () and equals () methods are also used when we try to get value from the HashMap. If hashCode() and equals() method is not define correctly, two other key’s might obtain same hashCode() and equals() result and in that situation rather than STORING it at other LOCATION, the HashMpa will determine them same and overwrite them. So, we can say that, the collection classes that does not duplicate data use hashCode() equals() to determine duplicate data so these methods it is very necessary to define correctly.

A HashMap is used for key object where as hashCode() and equals() method to consider the index to out the key value pair. The hashCode () and equals () methods are also used when we try to get value from the HashMap. If hashCode() and equals() method is not define correctly, two other key’s might obtain same hashCode() and equals() result and in that situation rather than storing it at other location, the HashMpa will determine them same and overwrite them. So, we can say that, the collection classes that does not duplicate data use hashCode() equals() to determine duplicate data so these methods it is very necessary to define correctly.



Discussion

No Comment Found