119. What is hashCode? If the hashCode() of two objects is the same, equals() must also be true, right? **

What is hashCode? If the hashCode() of two objects is the same, equals() must also be true, right?

Use hashCode to generate a hash value for comparison

Not as complicated as equals, hashCode is very efficient

But the hashCode is not completely reliable. Sometimes there is a problem with the formula algorithm. The hashCode of the two values ​​are equal, but they are different values.

No, the hashCode() of the two objects is the same, equals() is not necessarily true.

Conversely, if equals are equal, hashCode must be equal.

Guess you like

Origin blog.csdn.net/weixin_43206161/article/details/112324515