/home/oracle/labs/16ParallelStreams/examples/EmployeeSearch16/src/com/example/lambda/A08Reduction.java
 1 package com.example.lambda;
 2 
 3 import java.util.stream.IntStream;
 4 
 5 /**
 6  *
 7  * @author oracle
 8  */
 9 public class A08Reduction {
10     
11     public static void main(String[] args) {
12         
13         int r1 = IntStream.rangeClosed(1, 5).parallel()
14             .reduce(0, (a, b) -> a + b);
15         
16         System.out.println("Result: " + r1);
17         
18         int r2 = IntStream.rangeClosed(1, 5).parallel()
19             .reduce(0, (sum, element) -> sum + element);
20         
21         System.out.println("Result: " + r2);
22         
23     }
24     
25 }
26