java ——MAP集合的遍历

测试代码:

	public static void main(String[] args) throws FileNotFoundException {	
		Map datas = new HashMap();
		datas.put("key1", "value1");
		datas.put("key2", "value2");
		datas.put("key3", "value3");
		
		Set> dataEntrys = datas.entrySet();
		for (Entry data : dataEntrys) { 
			System.out.println("key:" + data.getKey() + " --- value:" + data.getValue());
		}
			
	}

 

结果:

key:key3 --- value:value3
key:key2 --- value:value2
key:key1 --- value:value1

 

你可能感兴趣的:(java-util,MAP集合的遍历)