1、方法一
List<Integer> result = new ArrayList(map.keySet());
List<String> result2 = new ArrayList(map.values());
2、方法二
List<Integer> result = map.keySet().stream().collect(Collectors.toList());
List<String> result2 = map.values().stream().collect(Collectors.toList());
参考博客:https://blog.csdn.net/HD243608836/article/details/85258565