Java中Map獲取key和value
阿新 • • 發佈:2019-02-04
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值
}
}
}