- Instance
List<BlogComment> blogCommentListResult = new ArrayList<>(blogCommentMap.values());
- Map data is converted into a list of custom objects, for example, the key and value of the map correspond to two attributes of the Person object:
List<Person> list = map.entrySet().stream().sorted(Comparator.comparing(e -> e.getKey()))
.map(e -> new Person(e.getKey(), e.getValue())).collect(Collectors.toList());
List<Person> list = map.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getValue))
.map(e -> new Person(e.getKey(), e.getValue())).collect(Collectors.toList());
List<Person> list = map.entrySet().stream().sorted(Map.Entry.comparingByKey())
.map(e -> new Person(e.getKey(), e.getValue())).collect(Collectors.toList());
The difference between the above three methods is the sorting processing