Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
import java.util.stream.*;
Silly reminider of streams
Stream sum of even numbers includeing 2 up to including N. Go to the Java streams cheat sheet for more.
1
6
7
8
9
10
11
16
17
// {
int N=4;
System.out.println(IntStream.rangeClosed(2,N).filter(x -> x%2==0).sum());
// 6
//{
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content