标签:
public class Test {
public static void main(String[] args) {
Person person1 = new Person();
person1.setId("1");
person1.setName("qiumc");
Person person2 = new Person();
person2.setId("1");
person2.setName("qiumc");
Map<Person, String> hashMap = new HashMap<Person, String>();
hashMap.put(person1,"1");
hashMap.put(person2,"2");
System.out.println(hashMap.size());//重写hashCode 结果为1,否则为2
}
}
//Person类省略,只有两个属性,一个是name,一个id
标签:
原文地址:http://www.cnblogs.com/qiumingcheng/p/5215063.html