// map遍历
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
map.put(1, 2);
// 1. entrySet遍历,在键和值都需要时使用(最常用)
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
}
//map排序
HashMap<String, String> maptest =new HashMap<String, String>();
maptest.put("1天","day1");
maptest.put("5天","day5");
maptest.put("4天","day4");
maptest.put("2天","day2");
maptest.put("3天","day3");
Collection<String> keyset= maptest.keySet();
List<String> list = new ArrayList<String>(keyset);
//对key键值按字典升序排序
Collections.sort(list);