java 遍历Map

  直接上代码:

		/*遍历MAP*/
		Map<String, String> map = new HashMap<String, String>();
		map.put("key1", "123");
		map.put("key2", "adb");
		Set<Entry<String, String>> set = map.entrySet();
		Iterator<Entry<String, String>> it = set.iterator();
		for(;it.hasNext();){
			Entry<String, String> entry = it.next();
			System.out.println("key = " + entry.getKey() + "; value = " + entry.getValue());
		}


你可能感兴趣的:(java,遍历,map)