asdfdsf

 1 package com.journaldev.util;
 2
 3 import java.util.HashMap;
 4 import java.util.Iterator;
 5 import java.util.Map;
 6 import java.util.concurrent.ConcurrentHashMap;
 7
 8 public class ConcurrentHashMapExample {
 9
10     public static void main(String[] args) {
11
12         //ConcurrentHashMap
13         Map<String,String> myMap = new ConcurrentHashMap<String,String>();
14         myMap.put("1", "1");
15         myMap.put("2", "1");
16         myMap.put("3", "1");
17         myMap.put("4", "1");
18         myMap.put("5", "1");
19         myMap.put("6", "1");
20         System.out.println("ConcurrentHashMap before iterator: "+myMap);
21         Iterator<String> it = myMap.keySet().iterator();
22
23         while(it.hasNext()){
24             String key = it.next();
25             if(key.equals("3")) myMap.put(key+"new", "new3");
26         }
27         System.out.println("ConcurrentHashMap after iterator: "+myMap);
28
29         //HashMap
30         myMap = new HashMap<String,String>();
31         myMap.put("1", "1");
32         myMap.put("2", "1");
33         myMap.put("3", "1");
34         myMap.put("4", "1");
35         myMap.put("5", "1");
36         myMap.put("6", "1");
37         System.out.println("HashMap before iterator: "+myMap);
38         Iterator<String> it1 = myMap.keySet().iterator();
39
40         while(it1.hasNext()){
41             String key = it1.next();
42             if(key.equals("3")) myMap.put(key+"new", "new3");
43         }
44         System.out.println("HashMap after iterator: "+myMap);
45     }
46
47 }
package com.journaldev.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ConcurrentHashMapExample {

    public static void main(String[] args) {

        //ConcurrentHashMap
        Map<String,String> myMap = new ConcurrentHashMap<String,String>();
        myMap.put("1", "1");
        myMap.put("2", "1");
        myMap.put("3", "1");
        myMap.put("4", "1");
        myMap.put("5", "1");
        myMap.put("6", "1");
        System.out.println("ConcurrentHashMap before iterator: "+myMap);
        Iterator<String> it = myMap.keySet().iterator();

        while(it.hasNext()){
            String key = it.next();
            if(key.equals("3")) myMap.put(key+"new", "new3");
        }
        System.out.println("ConcurrentHashMap after iterator: "+myMap);

        //HashMap
        myMap = new HashMap<String,String>();
        myMap.put("1", "1");
        myMap.put("2", "1");
        myMap.put("3", "1");
        myMap.put("4", "1");
        myMap.put("5", "1");
        myMap.put("6", "1");
        System.out.println("HashMap before iterator: "+myMap);
        Iterator<String> it1 = myMap.keySet().iterator();

        while(it1.hasNext()){
            String key = it1.next();
            if(key.equals("3")) myMap.put(key+"new", "new3");
        }
        System.out.println("HashMap after iterator: "+myMap);
    }

}

  

时间: 2024-11-05 13:44:42

asdfdsf的相关文章

L8-DOM操作应用

DOM创建.插入.删除元素 DOM创建元素 createElement(标签名) 创建一个节点 appendChild(子节点) 追加一个节点 例子:为ul插入li <ul id = "ul1"></ul> var oUl = document.getElementById("ul1"); var oLi = document.createElement("li"); oUl.appendChild(oLi); 插入元素

Activity的按钮消息传递

底层的怎么调用我说不清楚, 我们来关注下activity的按钮消息传递. acitivty中有三个关于按键消息处理的方法.  dispatchKeyEvent 和onKeyDown ,onKeyUp . 由于Activity是View的子类, 所以这三个方法都是重写View的三个方法. 引用<android内核解析>中的一句话: 当按键消息进入activity的内部后, Acitivty内部的dispatchKeyEvent有默认的逻辑处理. 它先回调该Activity保函的window对象的

Python create a distribution for your moudle and func

1. create dir "nester" under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\ 2. create a nester.py under C:\Users\eric\AppData\Local\Programs\Python\Python35-32\nester\ """this is a new fuction, which work for a list"