System.identityHashCode

Object的hashCode方法是根据对象内存地址返回一个hash值,但是很多类都会重写hashCode方法。

JDK在System类中提供一个方法public static native int identityhashCode(Object x)

不管给的参数对象的类是否重载了hashCode()方法,identityHashCode方法都会返回Object类默认hashCode()方法会返回的值

猜你喜欢

转载自xiaoxiaoher.iteye.com/blog/2372388
今日推荐