加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java平台库Hashcode

发布时间:2020-05-24 03:24:53 所属栏目: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

在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 instance value.
This is generally not a good idea,as it severely limits your ability
to improve the hash function in future releases.

这是什么意思 ? 最佳答案 这意味着您无法在更高版本的代码中重写散列函数以获得更好的散列属性.例如,String.hashCode()函数很快……但不是很好.但它不能再被更改了,因为哈希代码已经指定,并且人们已经在自己的代码中依赖于该实现.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读