What does the auto-generated hashcodes and equals algorithms exactly do, and why? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

What does the auto-generated hashcodes and equals algorithms exactly do, and why?

For example, why hashcode override contains prime and result variables and their product is added to the name.hashcode() ? What does " class other = (class) obj " statement mean and why it has been integrated in equals() override? Where can we find a step by step explanations of those methods algorithms?

14th Oct 2016, 10:31 PM
Oğuz Kaan BULUT
Oğuz Kaan BULUT - avatar
1 Antwort
0
As far as I know the auto-generated hashCode() method returns the adress of that object in your computer memory. The basic equals() method compares those adresses.
30th Dec 2016, 9:39 PM
merkrafter