1
我有一個兩個對象的hashmap,但它似乎返回不同的值,因爲哈希碼是不同的。例如,HashMap的不同hashcodes返回不同的值? Java
HashMap<HashMapTest, String> newMap = new HashMap<HashMapTest, String>();
newMap.put(new HashMapTest("test"), "line");
System.out.println(newMap.get(new HashMapTest("test")));
當我把它放在散列表中,並且從散列表中得到它時,這些散列碼是不同的。有沒有解決這個問題的方法?
讓我們來看看你的'HashMapTest'類。 – weston 2012-04-21 16:37:25