hashmap中的clone为什么是shallow copy of this map

public Object clone() {
HashMap result = null;
try {
result = (HashMap)super.clone();
} catch (CloneNotSupportedException e) {
// assert false;
}
result.table = new Entry[table.length];
result.entrySet = null;
result.modCount = 0;
result.size = 0;
result.init();
result.putAllForCreate(this);

    return result;
}

新建Entry,把原来Entry中数据放到新的Entry中。新的HashMap与旧的HashMap操作没有关系了,为什么还是shallow?

javadoc上说得很清楚呀
[quote]
/**
* Returns a shallow copy of this HashMap instance: [color=red][b]the keys and
* values themselves are not cloned.[/b][/color]
*
* @return a shallow copy of this map
*/
[/quote]

因为里边的数据还是同一个,所以还是浅拷贝

深拷贝是子子孙孙都要复制

HashMap hm = new HashMap();
HashMap hm1 = new HashMap();
hm1.put("A", "AA");
hm.put(1, "A");
hm.put(2, hm1);
Object hmc = hm.clone();
hm1.put("A", "AAA");
hm1.put("B", "BBB");
System.out.println(hm.toString());
System.out.println(hmc.toString());

hm:{1=A, 2={A=AAA, B=BBB}}
hmc:{1=A, 2={A=AAA, B=BBB}}