Java System identityHashCode() 方法

2024 年 11 月 7 日 | 阅读 1 分钟

Java System 类的 identityHashCode() 方法返回指定对象的哈希码。它由默认的 hashCode() 方法返回。

语法

参数

x - 要计算其 hashCode 的对象

返回值

  1. 返回哈希码。
  2. 如果哈希码为 null,则返回零作为引用。

示例 1

输出

identity hash code of object a = 743673026
identity hash code of object b = 743673026
identity hash code of object c = 557722442

示例 2

输出

identity hash code of object a = 843730481
identity hash code of object b = 743673026