list里面有map,怎么遍历出来?

list里面有map,怎么遍历出来?
ArrayList list = new ArrayList();
Map map = new HashMap();
list.add(map);
怎么遍历得到map的键及key
ArrayList list = new ArrayList();
for(int i = 0; i < list.size(); i++) {
Map map = list.get(i);
Set set = map.keySet();
Iterator it = set.iterator();
while(it.hasNext()) {
System.out.println(map.get(it.next()));
}
}
看API。
for (Map map : list) {
Set set = map.keySet();
Iterator it = set.iterator();
while (it.hasNext()) {
Object key = it.next();
Object value = map.get(key);
}
}

这样可以把三类map的value都分别显示出来吵消拆?
List> result = null;

Map asset = new HashMap<>();
Map num = new HashMap<>();
Map<升枣String,String> rank = new HashMap<桥并>();



:


Map map = (Map)list.get(0);String str = (String)map.get("w");//str就是22


← 上一篇: 下一篇: →