求个android开发大神 帮我取出List<Map<String,Object>gt;中的值
答案:1 悬赏:30 手机版
解决时间 2021-01-27 16:24
- 提问者网友:动次大次蹦擦擦
- 2021-01-27 01:10
求个android开发大神 帮我取出List<Map<String,Object>gt;中的值
最佳答案
- 五星知识达人网友:青尢
- 2021-01-27 02:03
private static void test10(){
List<Map<String,Object>> maps = new ArrayList<>();
Map<String,Object> hashMap = new HashMap<>();
hashMap.put("key1","value1");
hashMap.put("key2","value2");
hashMap.put("key3","value3");
maps.add(hashMap);
hashMap = new HashMap<>();
hashMap.put("key11","value11");
hashMap.put("key21","value21");
hashMap.put("key31","value31");
maps.add(hashMap);
for (Map<String,Object> map:maps){
Set set = map.keySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()){
String key = (String) iterator.next();
Object value = map.get(key);
System.out.println(key);
System.out.println(value);
}
}
}
List<Map<String,Object>> maps = new ArrayList<>();
Map<String,Object> hashMap = new HashMap<>();
hashMap.put("key1","value1");
hashMap.put("key2","value2");
hashMap.put("key3","value3");
maps.add(hashMap);
hashMap = new HashMap<>();
hashMap.put("key11","value11");
hashMap.put("key21","value21");
hashMap.put("key31","value31");
maps.add(hashMap);
for (Map<String,Object> map:maps){
Set set = map.keySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()){
String key = (String) iterator.next();
Object value = map.get(key);
System.out.println(key);
System.out.println(value);
}
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯