歡迎您光臨本站 註冊首頁

JAVA 遍歷Map所有元素

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  //JDK1.5

  Map m = new HashMap();

  for (Object o : map.keySet()){

  map.get(o);

  }

  JDK1.4

  Map map = new HashMap() ;

  Iterator it = map.entrySet().iterator() ;

  while (it.hasNext())

  {

  Map.Entry entry = (Map.Entry) it.next() ;

  Object key = entry.getKey() ;

  Object value = entry.getValue() ;

  }


[火星人 ] JAVA 遍歷Map所有元素已經有267次圍觀

http://coctec.com/docs/java/show-post-60710.html