In this post, we will see how to double the even and odd numbers present in an ArrayList separately with the help of Java 8 Streams.

Let’s say: There is an ArrayList of 10 integer values as shown below. In the first example, using Streams, we are going to double each even integer of the ArrayList and In the second example, we are going to double odd integers.

Example 1

Output:

 

Example 2

Output:

 

That’s it. It’s that easy to double the even and odd numbers of ArrayList with the power of Java 8 Streams.

If you like this post, please check out my other similar posts:

How to add/sum up the ArrayList integers using Java8 Streams

 

Reference:

     Java 8 Streams