List中的Map
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; public class Demo { public static void main(String[] args) { List<Map<String,Map<String,Object>>> list=new ArrayList<Map<String,Map<String,Object>>>(); Map<String, Object> map1=new HashMap<String,Object>(); map1.put("1", "我爱中国"); map1.put("2", "我爱中国"); map1.put("3", "我爱中国"); Map<String, Object> map2=new HashMap<String,Object>(); map2.put("1", "我爱中国"); map2.put("2", "我爱中国"); map2.put("3", "我爱中国"); Map<String, Object> map3=new HashMap<String,Object>(); map3.put("1", "我爱中国"); map3.put("2", "我爱中国"); map3.put("3", "我爱中国"); Map<String,Map<String,Object>> map12=new HashMap<String,Map<String,Object>>(); map12.put("1", map1); map12.put("2", map2); map12.put("3", map3); Map<String,Map<String,Object>> map13=new HashMap<String,Map<String,Object>>(); map13.put("1", map1); map13.put("2", map2); map13.put("3", map3); Map<String,Map<String,Object>> map14=new HashMap<String,Map<String,Object>>(); map14.put("1", map1); map14.put("2", map2); map14.put("3", map3); list.add(map12); list.add(map13); list.add(map14); for(Map<String,Map<String,Object>> map:list){ Set<String> set=map.keySet(); for(String s:set){ System.out.println(s+" "); Map<String,Object> map11=map.get(s); Set<String> sets=map11.keySet(); for(String ss:sets){ System.out.print(" "+ss+" "+map11.get(ss)+" "); } } System.out.println(); } } }