class temp
{
int number;
temp(int i)
{
number=i;
}
public static void main(String[] args)
{
temp t=new temp(1);
temp t2=new temp(1);
System.out.println(t.hashCode()+"\t"+t2.hashCode());

String str=new String("ok");
String str2=new String("ok");
System.out.println(str.hashCode()+"\t"+str2.hashCode());
}
}在上面两个temp的对象用hashCode()方法产生的值是不同的,两个String的对象用hashCode()方法所产生的值是相同的。这是为什么,各位朋友帮忙解答一下,谢谢啦!