Object.hashCode()算法 [英] Object.hashCode() algorithm

查看:162
本文介绍了Object.hashCode()算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找 Object.hashCode()的算法。

此代码在中是原生的的 Object.java

This code is native in Object.java.

这是因为

(a)代码是汇编 -
从未进入Java或任何其他HLL

(a) the code is in assembly-- never was in Java or any other HLL at all

(b)它只是不公开

在任何一种情况下,我都希望得到如何 hashCode()的算法(伪代码或一些详细说明)计算 - 计算中的参数和计算本身是什么?

In either case, I am looking to get hold of the algorithm (pseudo-code or some detailed explanation) of "how hashCode() is calculated"-- what are the params going into its calculation and the calculation itself?

请注意:这是 hashCode() 对象 我正在寻找 -
不是像 String hashMap / table 那样的。

Please note: It's the hashCode() of Object i'm looking for-- not another like that of String or hashMap/table.

// ================================= =========================================

//==========================================================================

新的Java文档 - jdk 8现在说

the new Java docs-- jdk 8 now saying

"The value returned by hashCode() is the object's hash code, which is the object's memory address in hexadecimal." 


推荐答案

原生 hashCode 方法实现取决于 JVM 。默认情况下,它在HotSpot中返回随机数,您可以在源代码(函数 get_next_hash

Native hashCode method implementation depends on the JVM. By default in HotSpot it returns random number, you can check it in the source code (function get_next_hash)

这篇关于Object.hashCode()算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆