`

遍历Map

    博客分类:
  • J2SE
 
阅读更多
	public static void main(String[] args) {
		Map map = new HashMap();
		map.put("1", "a");
		map.put("2", "b");
		Iterator it = map.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry entry = (Map.Entry) it.next();
			String key = (String)entry.getKey();
			String value = (String)entry.getValue();
			System.out.println("key=" + key);
			System.out.println("value=" + value);
		}

	}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics