Java平台库Hashcode
发布时间:2020-12-14 19:23:05 所属栏目:Java 来源:网络整理
导读:在Effective Java Item 9中(当你覆盖equals时总是覆盖hashCode) Many classes in the Java platform libraries,such as String, Integer,and Date,include in their specifications the exact value returned by their hashCode method as a function of the
在Effective Java Item 9中(当你覆盖equals时总是覆盖hashCode)
这是什么意思 ? 最佳答案
这意味着您无法在更高版本的代码中重写散列函数以获得更好的散列属性.例如,String.hashCode()函数很快……但不是很好.但它不能再被更改了,因为哈希代码已经指定,并且人们已经在自己的代码中依赖于该实现.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |