We generally iterate through the list for addition of integers in a range, but ava.util.stream.Stream has sum() method when used with filter() gives the required result easily.
The above task can be easily performed using sum() method with filter() method
- Stream filter() in Java with examples
- Program to Convert List to Stream in Java
- Initialize a list in a single line with a specified value using Java Stream
- Difference between Stream.of() and Arrays.stream() method in Java
- Character Stream Vs Byte Stream in Java
- LongStream filter() in Java with examples
- DoubleStream filter() in Java with examples
- IntStream filter() in Java with examples
- Optional filter() method in Java with examples
- Java Stream | Collectors toCollection() in Java
- Java 8 Stream
- Stream In Java
- Stream of() method in Java
- Stream.of(T t) in Java with examples
- Stream.concat() in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.