package test02;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TEST07 {
public static void main(String[] args) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> map1=new HashMap<>();
map1.put("城市","西安");
map1.put("人口","1400万");
map1.put("GDP","11000万");
list.add(map1);
// Map<String, String> map2=new HashMap<>();
// map2.put("城市","上海");
// map2.put("人口","2200万");
// map2.put("GDP","20000万");
// list.add(map2);
for (int i = 0; i < list.size(); i++) {
Set<Map.Entry<String, String>> entries = list.get(i).entrySet();
for (Map.Entry<String, String> entry : entries) {
String key = entry.getKey();
String value = entry.getValue();
System.out.println(key +"=========="+value);
}
}
}
}
输出:文章来源:https://www.toymoban.com/news/detail-518245.html
人口==========1400万
GDP==========11000万
城市==========西安
Map循环:(Value为Object)文章来源地址https://www.toymoban.com/news/detail-518245.html
Map<String, Object> paramMap = new HashMap<>();
Iterator<Map.Entry<String, Object>> it = paramMap.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String, Object> entry = it.next();
System.out.println("99:"+"key="+entry.getKey()+" value="+entry.getValue());
}
到了这里,关于<List<Map<String,Object>>>循环List Map获取里面的key和value,进行操作的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!