Stream操作双列集合
双列集合:转换成单列集合后再创建
Map<String,Integer> map = new HashMap<>();
map.put("蜡笔小新",19);
map.put("黑子",17);
map.put("日向翔阳",16);
Stream<Map.Entry<String, Integer>> stream = map.entrySet().stream();
HashMap<String,Integer> personHashMap = new HashMap<String,Integer>();
personHashMap.put("蜡笔小新",19);
personHashMap.put("黑子",17);
personHashMap.put("日向翔阳",16);
System.out.println(personHashMap);
Stream<Map.Entry<String, Integer>> streams = personHashMap.entrySet().stream();
Map<String, Integer> newPersonHashMap = streams.filter(stream -> stream.getValue() > 17)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
System.out.println(newPersonHashMap);