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

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…

Contents