0

why use hashCode()

why we use hashCode() for equals ?

21st Dec 2016, 11:22 AM
Muktashim & Rosmalina
Muktashim & Rosmalina - avatar
1 ответ
+ 3
Hascode is a number that is obtained in base to an algorithm (usually involves the properties of your object in the operations, that's why generally you have to override the method from the original in object class) so than number is the result and is unique (we hope) Then you override the equal method to search if 2 hascode numbers are equals and because that numbers were obtained from the object properties, if they are equal you can assume that 2 objects are the same
21st Dec 2016, 3:01 PM
Dago VF
Dago VF - avatar