- インスタンス
List<BlogComment> blogCommentListResult = new ArrayList<>(blogCommentMap.values());
- マップデータはカスタムオブジェクトのリストに変換されます。たとえば、マップのキーと値は、Personオブジェクトの2つの属性に対応します。
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());
上記の3つの方法の違いは、並べ替え処理です