Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Here are a few micro kata's for you to solve, let's get to know some more possibilities of Streams!
If you want to know if your solution is optimal you can take look at the source & solutions.
The kata's are written in old-style Java code. Re-write them into beautiful one-liners using Streams.
Remember, you can find the documentation on Streams right here.
Not very interesting as an exercise, but check out this example of how to easily generate numerical statistics from an IntStream.
Write a method that returns a comma separated string based on a given list of integers. Each element should be preceded by the letter 'e' if the number is even, and preceded by the letter 'o' if the number is odd. For example, if the input list is (3,44), the output should be 'o3,e44'.
You can write this using only one operator and one collect statement. Go here and click 'Solution' if you want to see the optimal solution.