Based on Collectors documentation it's as simple as:

Map<String, Choice> result =
    choices.stream().collect(Collectors.toMap(Choice::getName,
                                              Function.identity()));
Answer from zapl on Stack Overflow
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java8 โ€บ java 8 โ€“ convert list to map
Java 8 โ€“ Convert List to Map | mkyong.com
May 26, 2017 - Map<String, Long> result1 = list.stream().collect( Collectors.toMap(Hosting::getName, Hosting::getWebsites, (oldValue, newValue) -> newvalue ) ); ... package com.mkyong.java8; import java.util.*; import java.util.stream.Collectors; public class TestSortCollect { public static void main(String[] args) { List<Hosting> list = new ArrayList<>(); list.add(new Hosting(1, "liquidweb.com", 80000)); list.add(new Hosting(2, "linode.com", 90000)); list.add(new Hosting(3, "digitalocean.com", 120000)); list.add(new Hosting(4, "aws.amazon.com", 200000)); list.add(new Hosting(5, "mkyong.com", 1)); list.add(n
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java collections โ€บ java map โ€บ how to convert list to map in java
How to Convert List to Map in Java | Baeldung
April 4, 2025 - A solid grasp of the fundamentals will go a long way to help minimize these issues. Get started with understanding multi-threaded applications with our Java Concurrency guide: ... Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 680277 โ€บ java โ€บ Creating-map-maps-list-Java
Creating a map of maps from a list using Java 8 streams [Solved] (Java in General forum at Coderanch)
The key of the first map is MonitoredData::getDayOfYear and the key to the second map is MonitoredData::getActivityLabel. The value of the second data should be the number of times the certain activity has been found in that specific day. Thanks in advance, tell me if there's something else ...
๐ŸŒ
Medium
medium.com โ€บ @alxkm โ€บ converting-a-list-to-a-map-in-java-multiple-approaches-1cf111e828cc
Java Interview: Converting a List to a Map in Java: Multiple Approaches | by Alex Klimenko | Medium
July 11, 2025 - Converting a List to a Map is a frequent task in Java, especially when working with collections of objects. With Java 8 and newer, this process has become much simpler thanks to the Stream API.
๐ŸŒ
Marc Nuri
blog.marcnuri.com โ€บ home โ€บ java streams: convert list into map
Java Streams: Convert List into Map - Marc Nuri
January 27, 2026 - When you're certain that the List ... is to convert the list into a Stream and then collect the results using Collectors.toMap(). For the Map key, we use Repository::name (a method reference equivalent to r -> r.name())...
๐ŸŒ
Oracle
docs.oracle.com โ€บ javase โ€บ 8 โ€บ docs โ€บ api โ€บ java โ€บ util โ€บ Map.html
Map (Java Platform SE 8 )
July 21, 2026 - All general-purpose map implementation classes should provide two "standard" constructors: a void (no arguments) constructor which creates an empty map, and a constructor with a single argument of type Map, which creates a new map with the same key-value mappings as its argument. In effect, the latter constructor allows the user to copy any map, producing an equivalent map of the desired class.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ program-to-convert-list-to-map-in-java
Program to Convert List to Map in Java - GeeksforGeeks
September 4, 2026 - A List is an ordered collection that can contain duplicate elements, while a Map stores data in the form of key-value pairs. Java provides several ways to convert a List of objects into a Map based on a key and a value.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2016 โ€บ 04 โ€บ 10-examples-of-converting-list-to-map.html
10 Examples of Converting a List to Map in Java 8
In the past, we have seen how to use the Collectors.groupingBy() method to group elements in Set and In this article, we will use Collectors.toMap() method to convert a List of an object into a Map in Java.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 698071 โ€บ java โ€บ Converting-List-Map
Converting from List To Map? (Features new in Java 8 forum at Coderanch)
August 21, 2018 - With the toMap, it means that when we have two equal Strings, we need to put the two associated Words into a List. Now, that is not so easy to accomplish with the toMap method, but the alternative mappng method is in this case very much easier. I'm talking about the Collectors.groupingBy method.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ conversion-of-java-maps-to-list
Conversion of Java Map to List - GeeksforGeeks
July 11, 2025 - In Java, a Map is a collection that maps keys to values and a list is an ordered collection of objects and the List can contain duplicate values. There are some scenarios where we need to convert a Map into a List.
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java8 โ€บ java 8 โ€“ convert map to list
Java 8 โ€“ Convert Map to List | mkyong.com
May 24, 2017 - Map<String, String> map = new HashMap<>(); // Convert all Map keys to a List List<String> result = new ArrayList(map.keySet()); // Convert all Map values to a List List<String> result2 = new ArrayList(map.values()); // Java 8, Convert all Map ...
Top answer
1 of 4
29

Well, you want to collect Pair elements into a List. That means that you need to map your Stream<Map.Entry<String, Double>> into a Stream<Pair<String, Double>>.

This is done with the map operation:

Returns a stream consisting of the results of applying the given function to the elements of this stream.

In this case, the function will be a function converting a Map.Entry<String, Double> into a Pair<String, Double>.

Finally, you want to collect that into a List, so we can use the built-in toList() collector.

List<Pair<String, Double>> mostRelevantTitles = 
    implicitDataSum.entrySet()
                   .stream()
                   .sorted(Comparator.comparing(e -> -e.getValue()))
                   .map(e -> new Pair<>(e.getKey(), e.getValue()))
                   .collect(Collectors.toList());

Note that you could replace the comparator Comparator.comparing(e -> -e.getValue()) by Map.Entry.comparingByValue(Comparator.reverseOrder()).

2 of 4
9

Note that if you want efficient implementation, you should consider this:

List<Pair<String, Double>> mostRelevantTitles = 
    implicitDataSum.entrySet()
                   .stream()
                   .map(e -> new Pair<>(e.getKey(), e.getValue()))
                   .collect(Collectors.toList());
mostRelevantTitles.sort(Comparators.comparing(Pair::getSecond, Comparator.reverseOrder()));

I assume that your Pair class have getSecond getter.

Using the sorted() stream pipeline step you create intermediate buffer, store everything to that buffer, convert it into array, sort that array, then store the result into the ArrayList. My approach, though less functional, stores data directly into the target ArrayList, then sorts it in-place without any additional copying. So my solution would take less time and intermediate memory.

๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java collections โ€บ java map โ€บ converting hashmap values to an arraylist in java
Converting HashMap Values to an ArrayList in Java | Baeldung
June 9, 2025 - The Lists class comes with the newArrayList() method, which creates a new ArrayList based on the given elements. As shown above, we used a custom EntryTransformer to get the value from the key-value pair. Then, we passed our transformer to the Maps.transformEntries() method alongside the HashMap.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ java-convert-map-to-list
Java 8: How to Convert a Map to List
October 10, 2023 - A Java Map implementation is an collection that maps keys to values. Every Map Entry contains key/value pairs, and every key is associated with exactly one value.
๐ŸŒ
DEV Community
dev.to โ€บ realnamehidden1_61 โ€บ java-8-map-vs-flatmap-4l4a
Java 8 โ€” map() vs flatMap() - DEV Community
August 15, 2025 - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class MapVsFlatMap { public static void main(String[] args) { List<List<String>> nestedList = Arrays.asList( Arrays.asList("java", "spring"), Arrays.asList("hibernate", "jpa") ); // Using map() List<List<String>> mappedResult = nestedList.stream() .map(list -> list.stream() .map(String::toUpperCase) .collect(Collectors.toList())) // still a list inside a list .collect(Collectors.toList()); System.out.println("map() result:"); System.out.println(mappedResult); // [[JAVA, SPRING], [HIBERNATE, JPA]] // Using flatMap() List<String> flatMappedResult = nestedList.stream() .flatMap(list -> list.stream()) // flatten before collecting .map(String::toUpperCase) .collect(Collectors.toList()); System.out.println("\nflatMap() result:"); System.out.println(flatMappedResult); // [JAVA, SPRING, HIBERNATE, JPA] } }
๐ŸŒ
Experts CENELEC
experts.cenelec.eu
CENELEC Expert Area - Experts CENELEC
The Technical Body Dashboard (TB) is meant to gather on the longer term, actions to be performed by the Technical Body Secretary. Currently it gives access to Submission Interface and to the creation/activation of NWI/PWI but should, in the future, be integrated with other tools used by TB Officers.
๐ŸŒ
CA
parks.ca.gov
Malibu Creek State Park
Special rates may apply for peak season, high demand holiday periods, and during weekends. Prices are subject to change without notice. ... The park is located four miles south of Highway 101 on Las Virgenes/Malibu Canyon Road. ... View other park publications including infosheets, brochures, campground maps and more.
๐ŸŒ
Food @ OSU
food.oregonstate.edu
Food @ OSU | Oregon State University
Welcome to Oregon State dining, where you'll find tasty food and beverages at restaurants, cafes and markets across our beautiful campus.
๐ŸŒ
Benchresources
benchresources.net โ€บ home โ€บ java โ€บ java โ€“ conversion of list to map
Java - Conversion of List to Map - BenchResources.Net
June 26, 2022 - package in.bench.resources.list.to.map; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ConvertListToMap { public static void main(String[] args) { // create ArrayList List<Employee> employees = new ArrayList<Employee>(); // add employee objects to list employees.add(new Employee(1001, "SJ", 18, "Consultant")); employees.add(new Employee(1002, "AK", 20, "Enginner")); employees.add(new Employee(1003, "PJ", 23, "Developer")); // printing to console - List of Employee System.out.println("List of Employee : \n" + employees); // create