String s1=new String("abc") 与 String s2=new String("abc")的hashCode为什么是相等的
[此贴子已经被作者于2006-10-3 23:09:16编辑过]
建议你看一看String类的hashCode方法public int hashCode() { int h = hash; if (h == 0) { int off = offset; char val[] = value; int len = count;
for (int i = 0; i < len; i++) { h = 31*h + val[off++]; } hash = h; } return h; }