1. 提高具有哈希结构容器的效率。
2. 两个引用,如果指向的是同一个对象,则hash值肯定是一样的。
3. 两个引用,如果指向的是不同对象,则hash值是不一样的。
4. hash值主要是根据地址号来的,不能完全将hash值等同于地址号。
如案例中, aa的hashcode和aa1不同, aa的hashcode和bb相同
package org.example.object_;
public class HashCode_ {
public static void main(String[] args) {
AA aa = new AA();
AA aa1 = new AA();
System.out.println(aa.hashCode());
System.out.println(aa1.hashCode());
AA bb = aa;
System.out.println(bb.hashCode());
}
}
class AA{}



