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

posted @ 2019-02-11 16:34  narojay  阅读(145)  评论(0编辑  收藏  举报