java 返回对象地址_Java的Object.hashCode()的返回值到底是不是对象内存地址?

1 /**

2 * Returns a hash code value for the object. This method is3 * supported for the benefit of hash tables such as those provided by4 * {@linkjava.util.HashMap}.5 *

6 * The general contract of {@codehashCode} is:7 *

  • 8 *
  • Whenever it is invoked on the same object more than once during9 * an execution of a Java application, the {@codehashCode} method10 * must consistently return the same integer, provided no information11 * used in {@codeequals} comparisons on the object is modified.12 * This integer need not remain consistent from one execution of an13 * application to another execution of the same application.14 *
  • If two objects are equal according to the {@codeequals(Object)}15 * method, then calling the {@codehashCode} method on each of16 * the two objects must produce the same integer result.17 *
  • It is not required that if two objects are unequal18 * according to the {@linkjava.lang.Object#equals(java.lang.Object)}19 * method, then calling the {@codehashCode} method on each of the20 * two objects must produce distinct integer results. However, the21 * programmer should be aware that producing distinct integer results22 * for unequal objects may improve the performance of hash tables.23 *
24 *

25 * As much as is reasonably practical, the hashCode method defined by26 * class {@codeObject} does return distinct integers for distinct27 * objects. (This is typically implemented by converting the internal28 * address of the object into an integer, but this implementation29 * technique is not required by the30 * Java™ programming language.)31 *32 *@returna hash code value for this object.33 *@seejava.lang.Object#equals(java.lang.Object)34 *@seejava.lang.System#identityHashCode35 */

36 public native int hashCode();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值