1.定义
Map<String, Integer> map = new HashMap<String,Integer>();

2.判断map中是否存在某个键的值:
if(map.get(s)==null) 

3.给map中某个键赋值:
map.put(s, value);

4.map的遍历:
法一:
Set<String> key = map.keySet();
        for(String k:key) {
            System.out.println(k+":"+map.get(k));
        }


法二:
        Iterator<String> it = key.iterator();
        while(it.hasNext()) {
            String s = it.next();
            System.out.println(s+":"+map.get(s));
     }
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄