首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

HashMap 中 public void putAll(Map< extends K, extends V> m) 的用法

2012-12-26 
HashMap 中public void putAll(Map? extends K,? extends V m) 的用法//从指定映射中将所有映射关系复制

HashMap 中 public void putAll(Map<? extends K,? extends V> m) 的用法

//从指定映射中将所有映射关系复制到此映射中


public class TestPutAll {
?public static void main(String[] args){
??HashMap map1=new HashMap();
??map1.put("a", 1);
??map1.put("b", 2);
??map1.put("c", 3);
??map1.put("d", 4);
??
??HashMap map= new HashMap();
??map.put("e", 5);
??map.put("f", 6);
??map.put("j", 7);
??????? map.putAll(map1);
???????
??????? Iterator ite=map.entrySet().iterator();
??????? while(ite.hasNext()){
??????? ?Map.Entry<String, Integer> entry=(Map.Entry<String, Integer>)ite.next();
??????? ?System.out.print(entry.getKey()+"/");
??????????? System.out.println(entry.getValue());
??????? }
?}

}

热点排行