import java.util.Objects;
/*
hashCode方法
在Object中的hashCode方法是怎样的?
public native int hashCode();
这个方法不是抽象方法,带有native关键字,底层调用的是c++程序
hashCode() 方法返回的是int类型的哈希码
实际上就是一个java对象的内存地址,经过哈希算法,得出的一个值
所以hashCode()方法的执行结果可以等同看做一个java对象的内存地址
*/
public class Test01{
public static void main(String[] args) {
Object object=new Object();
int hashCode1 =object.hashCode();
System.out.println(hashCode1);
Object object2=new Object();
int hashCode2 =object2.hashCode();
System.out.println(hashCode2);
}
}
运行结果: