0

What is equals() and hashCode() method of a class ?

Explain with example code which depicts real usage of equals() and hashCode() mehod of java.

1st Apr 2017, 11:48 AM
Sbk0103
Sbk0103 - avatar
2 Réponses
+ 1
Both come from Java.lang.Object equals: returns boolean, proofs for equlity. hashCode: Returns an int value based on the internals of the object. It is nessaccary for collection stuff. e.g. speed up collection. read this for further info: http://www.programcreek.com/2011/07/java-equals-and-hashcode-contract/
1st Apr 2017, 12:16 PM
Thomas Zenglein
Thomas Zenglein - avatar