From the course: Functional Programming with Java
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Applying streams - Java Tutorial
From the course: Functional Programming with Java
Solution: Applying streams
- [Instructor] Alright, well, hopefully you've given this challenge a try. Let's jump in and take a look at one possible solution to this challenge. So remember that what we had to do was make our filterAndTransform function here return the number names. That is the English words for all numbers in an array that were divisible by three. And furthermore, the challenge specified that we were only going to have single digit positive integers here. So what I started off by doing, and you could've done things a little bit differently, but what I started off by doing was just creating an array of strings with all of the names of the numbers from zero through nine in it. So here's what I did, as I said, numberNames =, and then I just said zero, one, and I went all the way through nine. (keyboard faintly clicking) All right, so there we go. And now that we have these, it should be pretty straightforward to take the numbers in this argument here, right? Which is a list. And basically convert…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Map in Java8m 4s
-
(Locked)
Filter in Java10m 30s
-
(Locked)
Reduce in Java7m 46s
-
(Locked)
Collect in Java8m 8s
-
(Locked)
Challenge: Stream exercises1m 24s
-
(Locked)
Solution: Stream exercises3m 59s
-
(Locked)
Combine list functions4m 47s
-
(Locked)
Parallel streams5m 26s
-
(Locked)
Challenge: Average salary calculator2m 57s
-
(Locked)
Solution: Average salary calculator4m 10s
-
(Locked)
Solution: Applying streams3m 31s
-
(Locked)
-
-