Created
May 12, 2017 03:09
-
-
Save rastadrian/f59475a67e8decef277dab6bfe185d79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private int withoutStreams() { | |
| int[] values = {1, 2, 3, 4, 5, 6, 7, 8}; | |
| int sum = 0; | |
| for (int value : values) { | |
| if (value > 3) { | |
| sum += value; | |
| } | |
| } | |
| return sum; | |
| } | |
| private int withStreams() { | |
| int[] values = {1, 2, 3, 4, 5, 6, 7, 8}; | |
| return Arrays.stream(values) | |
| .filter(value -> value > 3) | |
| .sum(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment