---
title: "Map取值技巧"
author: "Illy"
date: "2011-02-25T09:18:58Z"
tags: []
categories: ["编程语言"]
slug: "map"
draft: false
lastmod: "2011-02-25T09:48:56Z"
id: 926654
url: "https://illy.iteye.com/blog/926654"
---

```java

   Map map = new HashMap();
	  map.put("1", "one");
	  map.put("2", "two");
	  map.put("3", "three");
	  
	  Set keys = map.keySet();
	  Set keys2 = map.entrySet();
	  for(Iterator it = keys.iterator(); it.hasNext();) {
		  String key = (String)it.next();
		  String value = (String) map.get(key);
		  System.out.println(key + " " + value);
	  }
	  for(Iterator it2 = keys2.iterator();it2.hasNext();) {
		  Map.Entry e = (Map.Entry)it2.next();
		  Object k = e.getKey();
		  Object v = e.getValue();
		  System.out.println(k + " " + v);
	  }

```