HASHMAP 写下两个对象,对象的hashcode不同,就有两个key

HASHMAP 写入两个对象,对象的hashcode不同,就有两个keyclass test {int idString name zhqang}HashM

HASHMAP 写入两个对象,对象的hashcode不同,就有两个key

 class test {              int id;              String name = "zhqang";        }        HashMap<Object, String> params = new HashMap<Object, String>();        params.put(new test(), "1");        params.put(new test(), "2"); Iterator iter = params.entrySet().iterator();        while (iter.hasNext()) {            Map.Entry entry = (Map.Entry) iter.next();            Object key = entry.getKey();            Object val = entry.getValue();            System.out.print(entry.getValue());        }



结果
 $1test@1f3aa07 -> 1 $1test@1a33d48 -> 2