java基础-Map

2017-08-06  本文已影响4人  小庄bb

Map

常用的Map

ConcurrentHashMap

Map的遍历方法

    public static void MapDemo1(){
        
        for(Map.Entry<String, Integer> entry : map.entrySet()){
            System.out.println(entry.getKey());
            System.out.println(entry.getValue());
        }
        
    }
    
    public static void MapDemo2(){
        
        Collection<Integer> values = map.values() ;
        
        for(Iterator<Integer> it = values.iterator() ; it.hasNext() ;){
             Integer s = it.next();
             System.out.println(s);
        }
        
    } 
    
上一篇 下一篇

猜你喜欢

热点阅读