1.普通类对象
1. hashCode相同,不一定是同一个对象
2. 同一个对象的,hashCode值一定相同
2. 数值型的原始数据类型对应的包装类
只要值是一样的,hashCode就会是相同的。尽管不同的数值类型的包装类,计算hashCode的算法不一样,但是底层都是拿对应的原始数据类型的值去进行hashCode计算。
以Double类为例
3. 测试代码如下
/**
*hashCode相同,不一定是同一个对象
*同一个对象的,hashCode值一定相同
*
*-------------------------------------------------------------------------------
*普通对象的HashCode值源码解释:
*If two objects are equal according to the equals(Object) method, then calling
*the hashCode method on each of the two objects must produce the same integer result.
*--------------------------------------------------------