Since Java 8, there are some standard options to do this in JDK:

Collection<E> in = ...
Object[] mapped = in.stream().map(e -> doMap(e)).toArray();
// or
List<E> mapped = in.stream().map(e -> doMap(e)).collect(Collectors.toList());

See java.util.Collection.stream() and java.util.stream.Collectors.toList().

Answer from leventov on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › map-interface-in-java
Map Interface in Java - GeeksforGeeks
Use ConcurrentHashMap for thread-safe operations, or Collections.synchronizedMap() to make an existing map synchronized. ... import java.util.HashMap; import java.util.Map; public class Geeks{ public static void main(String[] args){ // Create a Map using HashMap Map<String, Integer> m = new HashMap<>(); // Adding key-value pairs to the map m.put("Geek1", 1); m.put("Geek2", 2); m.put("Geek3", 3); System.out.println("Map elements: " + m); } }
Published: August 31, 2026
People also ask

Which is faster: HashMap or TreeMap?
HashMap is faster for most operations because it uses hashing. TreeMap is slower as it maintains sorted order using a red-black tree.
🌐
wscubetech.com
wscubetech.com › resources › java › map
Map Interface in Java: Syntax, Methods, Examples & Uses
How to get all values from a Map?
Use values(), which returns a Collection of values.
🌐
wscubetech.com
wscubetech.com › resources › java › map
Map Interface in Java: Syntax, Methods, Examples & Uses
Can a Map have duplicate values?
Yes, values can be duplicated even if keys are unique.
🌐
wscubetech.com
wscubetech.com › resources › java › map
Map Interface in Java: Syntax, Methods, Examples & Uses
🌐
Java67
java67.com › 2015 › 01 › java-8-map-function-examples.html
Java 8 Stream map() function Example with Explanation | Java67
It can be any predefined function or a user-defined function. You not only can use the lambda expression but also method references. One example of Map in Java 8 is to convert a list of integers and then the square of each number.
🌐
W3Schools
w3schools.com › java › java_map.asp
Java Map
The Map interface is a part of the Java Collections Framework and is used to store key-value pairs.
🌐
WsCube Tech
wscubetech.com › resources › java › map
Map Interface in Java: Syntax, Methods, Examples & Uses
August 12, 2026 - Learn Java Map Interface with simple examples. Explore Map methods, types, implementations like HashMap & TreeMap, key-value pairs, uses & common operations.
🌐
Medium
medium.com › @AlexanderObregon › javas-stream-map-method-explained-df0d0d461d39
Java’s Stream.map() Method Explained | Medium
August 27, 2024 - One of the most common use cases for the map() method is transforming primitive data types. For example, consider a scenario where you have a list of numeric strings that need to be converted to integers.
🌐
W3Schools
w3schools.com › java › java_ref_hashmap.asp
Java HashMap Reference
The complete reference of Java HashMap methods, with descriptions and examples.
Find elsewhere
🌐
CodingBat
codingbat.com › doc › java-functional-mapping.html
Java Functional Mapping
In general, "mapping" is a strategy ... is an easy way to do mapping. As a first example, we'll use the "doubling" problem: given a list of integers, double each integer in the list....
🌐
GeeksforGeeks
geeksforgeeks.org › java › stream-map-java-examples
Stream map() in Java with examples - GeeksforGeeks
January 4, 2025 - Example 1 : Stream map() function with operation of number * 3 on each element of stream. Java · // Java code for Stream map(Function mapper) // to get a stream by applying the // given function to this stream.
🌐
Scaler
scaler.com › home › topics › java stream map()
Java Stream map() - Scaler Topics
June 22, 2024 - Now, let us consider one more example of the Java stream's map() method to extract the first 3 characters of a string in Java. ... In this example, we have used the substring() method in the map's mapper function to extract the first three characters from each of the strings in the list.
🌐
Tutorialspoint
tutorialspoint.com › java › java_map_interface.htm
Java - Map Interface
Following is an example to explain map functions using HashMap to add and remove elements to the map− · import java.util.HashMap; import java.util.Map; public class CollectionsDemo { public static void main(String[] args) { Map<String, String> m1 = new HashMap<>(); m1.put("Zara", "8"); m1.put("Mahnaz", "31"); m1.put("Ayan", "12"); m1.put("Daisy", "14"); System.out.println(); System.out.println(" Map Elements"); System.out.print("\t" + m1); m1.remove("Daisy"); System.out.println(" Map Elements"); System.out.print("\t" + m1); } }
🌐
Board Infinity
boardinfinity.com › blog › learn-about-map-stream-in-java
Map() Stream in Java with Example | Board Infinity
July 7, 2023 - Here are some examples that illustrate how the map() method works. 1. A List of Strings to Uppercase Here is a simple Java example showing how to convert a list of Strings to uppercase.
🌐
Stackify
stackify.com › an-introduction-to-java-map-what-it-is-and-how-it-works
An Introduction to Java Map: What It Is and How It Works - Stackify
November 26, 2024 - As seen in the Map hierarchy, LinkedHashMap extends HashMap but maintains the order of insertion. This makes the function highly useful when the order of elements matters, such as in a caching system or tracking the sequence of user actions. Similar to HashMap, LinkedHashMap allows null keys and values. Let’s take a look at an example. Here, LinkedHashMap keeps track of the order of recent actions. import java.util.LinkedHashMap; import java.util.Map; public class LinkedHashMapExample { public static void main(String[] args) { Map<Integer, String> recentActions = new LinkedHashMap<>(); recentActions.put(1, "Login"); recentActions.put(2, "Viewed Profile"); recentActions.put(3, "Added to Cart"); System.out.println("Recent actions: " + recentActions); } }
🌐
DZone
dzone.com › coding › languages › java 8 map, filter, and collect examples
Java 8 Map, Filter, and Collect Examples - DZone
June 21, 2018 - Learn how to use the map() function in Java 8 to transform an object to another and how to use the filter() to select an object based upon condition.
🌐
Medium
medium.com › javarevisited › how-to-use-streams-map-filter-and-collect-methods-in-java-1e13609a318b
How to use map, filter, and collect methods in Java Stream? Example Tutorial | by javinpaul | Javarevisited | Medium
January 25, 2024 - Here is the Java program to implement whatever I have said in the above section. You can run this program in IDE or from the command line and see the result. You can also experiment with using more map() functions or more filter() calls to make the composition longer and more sophisticated.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › map in java
Map Interface in Java: Comprehensive Tutorial with Examples
August 14, 2025 - Master the Java Map interface with our detailed guide covering HashMap, TreeMap, and LinkedHashMap implementations, key methods, and practical code examples.
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › util › Map.html
Map (Java SE 11 & JDK 11 )
January 20, 2026 - Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null. This method may be of use when combining multiple mapped values for a key. For example, to either create or append a String msg to a value mapping:
🌐
Medium
medium.com › @reetesh043 › java-collection-map-interface-1881d9294a8d
Java Collection: Map Interface. Introduction | by Reetesh Kumar | Medium
January 25, 2024 - EnumMap: A specialized Map implementation for use with enum type keys. In Java, we must import the java.util.Map package to use Map.
🌐
Belief Driven Design
belief-driven-design.com › functional-programm-with-java-map-filter-reduce-77e479bd73e
Functional Programming With Java: map, filter, reduce | belief driven design
September 30, 2020 - Sometimes the mapping function will return an arbitrary number of results, wrapped in another type, like java.util.List:
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java stream map()
Java Stream map() with Examples - HowToDoInJava
August 26, 2023 - Java 8 Stream.map() converts Stream to Stream. For each object of type X, a new object of type Y is created and put in the new Stream.