Skip to content

Commit 9042960

Browse files
committed
Update map.md #158
1 parent 114b784 commit 9042960

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/streams/map.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ Stream<Integer> numberStream = numbers.stream()
1313
.map(Integer::parseInt); // 1, 2, 3
1414
```
1515

16+
You can also call `.map` multiple times to apply multiple transformations.
17+
18+
```java,no_run
19+
var numbers = List.of("1", "2", "3");
20+
21+
Stream<Integer> numberStream = numbers.stream()
22+
.map(Integer::parseInt) // 1, 2, 3
23+
.map(x -> x * 2); // 2, 4, 6
24+
```
25+
1626
[^metaphor]: In the real life stream metaphor, this is akin to rocks getting polished
1727
by sand as they flow.
1828

0 commit comments

Comments
 (0)