为什么o对象的hashcode值变了?此对象不是没有进行任何操作吗?
程序1:
public class Temp {
public static void main(String[] args) {
Object o = new Object();
int[] a = new int[5];
// System.out.println("a hashcode:"+a.hashCode());
System.out.println("o hashcode:" + o.hashCode());
}
}
输出结果:o hashcode:366712642
程序2:
public class Temp {
public static void main(String[] args) {
Object o = new Object();
int[] a = new int[5];
System.out.println("a hashcode:"+a.hashCode());
System.out.println("o hashcode:" + o.hashCode());
}
}
输出结果:
a hashcode:366712642
o hashcode:1829164700
重复问题:为什么o对象的hashcode值变了?此对象不是没有进行任何操作吗?
相关分类