In Java 8 - Find sum of all even numbers between 1 to 5










Program/ Example -
//In Java 8 - Find sum of all even numbers between 1 to 5
       int sum1 = IntStream.of(1, 2, 3, 4, 5)
                 .filter(n -> n % 2 == 0).sum();  //n.e.  2 + 4
      


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 :