看板 java 關於我們 聯絡資訊
※ 引述《lin1000 (你是研究生嗎)》之銘言: : int hash = hash(k); : static int hash(Object x) { : int h = x.hashCode(); : h += ~(h << 9); : h ^= (h >>> 14); : h += (h << 4); : h ^= (h >>> 10); : return h; : } : static class Entry implements Map.Entry { : final Object key; : Object value; : final int hash; : Entry next; <------ Entry itself has a referece to another one : } : if (e.hash == hash && eq(k, e.key)) { <------ this line : Object oldValue = e.value; : e.value = value; : e.recordAccess(this); : return oldValue; : } : static boolean eq(Object x, Object y) { : return x == y || x.equals(y); : } 很好的示範, 這種層次的問題只要耐心 trace 一下 code, 就不需要有任何的猜測存在。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.62.106.24