In Java 8 - Find sum of all between 1 to 5 and add 10 to that











Program/ Example -
      //In Java 8 - Find sum of all between 1 to 5  and add 10 to that
      //using reduce method of IntStream
       System.out.println("--2");
       int reduced2 =
                 IntStream.of(1, 2, 3, 4, 5)
            .reduce(10, (x, y) -> x + y);   //n.e. 10 + 1 + 2 + 3 + 4 + 5
       System.out.println(reduced2);


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.





eEdit
Must read for you :