举例:
Map map = new HashMap();
Student st = new Stundet();
st.setName("AAA");
map.put("123",st);
st.setName("BBB");
map.put("456",st);
for (Map.Entry entry : map.entrySet()) {
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue().getName());
}
输出结果:
key= 123 and value= BBB
key= 456 and value= BBB
求大神讲解,为什么会被冲掉了