vk2001
发贴: 7
积分: 0
|
于 2004-08-09 18:04
A hashCode()that returns the same value for all instances whether they’re equal or not is still a legal—even appropriate— hashCode()method! For example: ===================== public int hashCode() { return 1492; } ========================= would not violate the contract. Two objects with an x value of 8 will have the same hashcode. But then again, so will two unequal objects, one with an x value of 12 and the other a value of -920. so,If the hashCode values are the same, the objects "might" be equal,not "must".
|