在java中,如果hashcode方法已经被覆盖,我们如何获取对象的原始hashcode值?
3 回答
3
你可以使用System.identityHashCode(Object)方法。
为给定对象返回与默认方法返回的相同的哈希码
hashCode(),无论给定对象的类是否覆盖hashCode()。引用的哈希码null为零。
于 2013-09-18T19:28:36.827 回答
1
对于Object哈希码,使用System.identityHashCode(Object o). 这个静态方法将提供Object#hashCode-like hashCodes,或者0为 null。
于 2013-09-18T19:36:23.007 回答
0
System.identityHashCode(object) 应该为您提供原始哈希码,无论覆盖的 hashcode() 方法返回什么。
于 2013-09-18T19:29:48.687 回答