Simad | Tutoriel JAVA8 N°10: Stream avancé partie 2 Transformation(MapToDdouble - MapToInt) @simad2288 | Uploaded July 2018 | Updated October 2024, 6 hours ago.
On this page we will provide java 8 Stream map() example. It returns a Stream instance processed by a given Function. map() returns the stream of objects and to get the stream of primitive data type such as IntStream, LongStream and DoubleStream, java 8 Stream provides the method as mapToInt(), mapToLong() and mapToDouble() respectively
Stream map() with Function
The syntax of Stream.map() method is as follows.
map(Function mapper)
We need to pass Function instance as lambda expression. This method returns Stream instance that has the result processed by given Function. This is an intermediate operation.
Convert Map to List using Stream map()
Here we will convert a HashMap into a List of objects using Stream.map() as an intermediate operation.
Convert List to another List using Stream map()
In this example we will convert a List of an object into another List of different object using Stream.map() as an intermediate operation.
ListToAnotherList.java
On this page we will provide java 8 Stream map() example. It returns a Stream instance processed by a given Function. map() returns the stream of objects and to get the stream of primitive data type such as IntStream, LongStream and DoubleStream, java 8 Stream provides the method as mapToInt(), mapToLong() and mapToDouble() respectively
Stream map() with Function
The syntax of Stream.map() method is as follows.
map(Function mapper)
We need to pass Function instance as lambda expression. This method returns Stream instance that has the result processed by given Function. This is an intermediate operation.
Convert Map to List using Stream map()
Here we will convert a HashMap into a List of objects using Stream.map() as an intermediate operation.
Convert List to another List using Stream map()
In this example we will convert a List of an object into another List of different object using Stream.map() as an intermediate operation.
ListToAnotherList.java