+ 4

What is hashCode() metod în Java and which is it utility?

19th May 2019, 4:07 PM
VV.
2 odpowiedzi
+ 3
HashCode() creates an hash code which you need for hashing (hashtable, hashmap, hashset...). There exists a contract between hashCode() and equals(). If two objects are equal the hashCode() must return same hash code for each object. Otherwise using hashmap/hashset would not work. You can also have look on my code (in the comments you'll find resources). https://code.sololearn.com/cK2H7CdVEq45/?ref=app
19th May 2019, 4:44 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Hi! Hashcode turns possible to compare objects.
20th May 2019, 11:38 PM
Rafael S Valle
Rafael S Valle - avatar