VOOZH about

URL: https://www.geeksforgeeks.org/java/conversion-of-java-maps-to-list/

⇱ Conversion of Java Map to List - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Conversion of Java Map to List

Last Updated : 11 Jul, 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. In this article, we will explore how to convert the keys, values, or entries from a Map into a List.

Ways to Convert Java Map to List

1. Converting Map Keys to a List

The Map interface provides a method keySet() that returns a set of all the keys in the map. We can convert this set into a list using the ArrayList constructor.

Example: This example demonstrates how to convert the keys of a Map into a List in Java.


Output
List of Keys: [Geek3, Geek2, Geek1]

2. Converting Map Values to a List

The Map interface provides a values() method that returns collection of all the values in the map. We can convert this collection into a list by passing it to the ArrayList constructor.

Example: This example demonstrates how to convert the values of a Map into a List in Java.


Output
List of values: [300, 200, 100]

3. Using Stream API to Convert Map Keys and Values to Lists

From Java 8, we can use the Stream API to make the conversion process even more easy and functional. We can stream the map key or values and collect them into a list.

Example: This example demonstrates how to convert the keys and values of a Map into separate List object using Java Streams.


Output
List of Keys using Streams: [Geek3, Geek2, Geek1]
List of Values using Streams: [300, 200, 100]
Comment