Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 569 Bytes

File metadata and controls

36 lines (25 loc) · 569 Bytes

Map:

Map is an intermediate operation used to transform each element of a stream into another value. It applies a function to every element and produces a new stream containing the transformed elements.

Example

List<Integer> result = List.of(1, 2, 3, 4).stream()
.map(n -> n * 2)
.toList();

System.out.println(result);

Output

[2, 4, 6, 8]

Previous: A Filter

Next: C Flat Map