1. 程式人生 > >Java中Map獲取key和value

Java中Map獲取key和value

Java Map獲取key和value的方法

    List<Map<String,Object>> list  =new ArrayList<Map<String,Object>>();
        if (null != list) {
                for (Map<String,Object> m : list) { 
                        Iterator iterators=m.entrySet().iterator();
                        while (iterators.hasNext()) {
                                Entry ent=(Entry) iterators.next();
                                String key =  (String) ent.getKey();//key值
                                String value = (String) ent.getValue();//value值
                        }
                }

     }