遍历Map

	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);
		}

	}

 

你可能感兴趣的:(map)