+ 4
What is hashCode() metod în Java and which is it utility?
2 Antworten
+ 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
+ 2
Hi!
Hashcode turns possible to compare objects.