推 mars90226: hashCode跟記憶體無關 05/24 20:48
→ mars90226: 他就是拿來計算hash需要的key而已 05/24 20:48
→ mars90226: hash需要這個key來判斷兩個Object是否一樣 05/24 20:48
推 swpoker: 這裡不是C++啊?!為什麼都記憶體位置東跟記億體使用西呢 05/24 21:11
→ swpoker: ????? 05/24 21:11
→ MonyemLi: hashmap key 會受hashcode影響,但hash並不是記憶體位置 05/24 21:43
→ noapaov: 主要是看到document api寫到 Object.hashCode()的定義 05/24 23:40
→ noapaov: This is typically implemented by converting the 05/24 23:41
→ noapaov: internal address of the object into an integer 05/24 23:41
※ 編輯: noapaov (114.34.181.227), 05/24/2015 23:42:00
推 ctrlbreak: 這邊指的位址在Java應該是物件的reference value 05/25 02:38
→ noapaov: 你說的參考值指的是參考位置嗎? 05/25 08:26
→ noapaov: 抱歉沒說清楚, 我指的都是hashCode()回傳值 05/25 08:26
推 Killercat: HashCode不見得是記憶體位置 05/25 16:21
→ Killercat: 有興趣可以看看String的HashCode怎麼實作的 05/25 16:21
→ Killercat: 去找一下OpenJDK原始碼翻一下吧 很好找的 05/25 16:21
→ Killercat: String hashCode()可能你看了會噗疵笑出來 05/25 16:21
推 tas72732002: 原PO是說Object類別的hashCode() 不是String覆寫後的 05/25 18:30
→ tas72732002: hashCode() 05/25 18:30
→ Killercat: 下面有提供比較全面的說法啦... XD 05/25 18:45
推 ctrlbreak: 我參考值指的就是你下一篇說的物件序號 05/25 20:26
→ ctrlbreak: 默認的hashCode一般是以物件序號為基礎去算出來的 05/25 20:27
→ realmeat: 寫了java到現在, 我還沒考慮過'記憶體位置'這東西 05/26 13:53
→ pttworld: 理論上是毋須探究的。頂多具備GC的概念就夠了。 05/26 15:37