首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

地图-list

2012-10-06 
map-listMap map new HashMap()map.put(a, 1)map.put(b, 2)List list new ArrayList()lis

map-list
Map map = new HashMap();
  map.put("a", "1");
  map.put("b", "2");
  List list = new ArrayList();
  list.add("3");
  list.add("4");
  map.put("c", list);

  Set set = map.entrySet();
  Iterator it = set.iterator();
  while (it.hasNext()) {
   Entry es = (Entry) it.next();
   if (es.getValue() instanceof java.util.List) {
    List li = (List) es.getValue();
    for (int i = 0; i < li.size(); i++) {
     System.out.println("--->" + li.get(i));
     System.out.println("-key>" + es.getKey());
    }
   } else {
    System.out.println("--->" + es.getValue());
    System.out.println("-key>" + es.getKey());
   }
  }

热点排行