Always override object.equals () And Object.hashcode () in The Same Time

zhaozj2021-02-16  74

Always override

Object.equals () And Object.hashcode () in The Same Time. I Had Met With Such Bugs Serveral Times and It Was a Hard Time For Me To Figure Out Su. Quotes: http://www-106.ibm. COM / westWorks / library / j-jtp06294.html

Hashing it out

In "

Hashing it out, "I Outlined the Basic Rules for Correctly Overriding

Object.equals () and

Object.hashcode (), in Particular That Equal Objects (According To

Equals ()) Must Have Equal

hashCode () values. While this rule is fairly easy to follow once you know it (and some IDEs have wizards for defining both for you in a consistent manner), if you override one these methods and forget to override the other, this bug of Can Be Very Difficult to Detect Through Inspection - Because The Error Is Not in The Code That Is Absent.

转载请注明原文地址:https://www.9cbs.com/read-16986.html

New Post(0)