Map的遍历的方法

#Map的遍历的方法

public class MapForeach {
	public static void main(String[] args) {
		Map<Integer, String> map =new HashMap<>();
		map.put(1, "test1");
		map.put(2, "test2");
		map.put(3, "test3");
		map.put(4, "test4");
		
		for(Map.Entry<Integer, String> entry : map.entrySet()) {
			System.out.println(entry.getKey()+"->"+entry.getValue());
		}
	}
	
	
}

原文地址:https://www.cnblogs.com/narojay/p/10812573.html