Teeing
Teeing API was introduced in jdk12, though concept is not new as you see in above pic.
So in Java also it is similar, you take 2 different actions on the same stream to split in 2 different collections then you merge those in collection into one.
One simple example is given below -
So in Java also it is similar, you take 2 different actions on the same stream to split in 2 different collections then you merge those in collection into one.
One simple example is given below -
When you execute the above then it filters the numbers into 2 groups & then using the final merge function it merges both the collections, giving the below output -
[3, 4, 8, 9, 12, 15, 16, 21, 27]
[3, 4, 8, 9, 12, 15, 16, 21, 27]