日期:2014-05-20 浏览次数:21091 次
HashMap map1 = new HashMap();
HashMap map2 = new HashMap();
for(Iterator it = map1.keySet().iterator() ; it.hasNext();){
String key = it.next().toString();
map2.put(key, map1.get(key));
}
------解决方案--------------------
public static void main(String args[]) {
HashMap map1 = null;
HashMap map2 = new HashMap();
map2.put("1", "Hello");map2.put("2", "World");
map1 =(HashMap)map2.clone();
System.out.println(map1);
System.out.println(map2);
map1.put("1",(String)map1.get("1") + "World");
System.out.println(map1);
System.out.println(map2);
}