java遍历各种集合

遍历Map
引用
       Map map = new HashMap();
       for(Object key : map.keySet()){
            System.out.println("key=" + key);
            System.out.println("value=" + map.get(key));
       }


遍历Properties
Enumeration<?> enu = properties.propertyNames();  
        while (enu.hasMoreElements()) {  
            Object key = enu.nextElement();  
            System.out.println(key);  
        }  

你可能感兴趣的:(java)