Collectors.teeing() Example – Java 12

Java 12 brought some useful additions and a newly added method ‘Collectors.teeing()’ is one of them. In this post, we will learn “What is teeing() method and how to use it?”. 

Here, we are going to learn the following things:

  1. What is Collectors.teeing() method?
  2. How to use it?

Collectors.teeing() method in Java 12...!!! Click To Tweet

 

Let’s Begin,

1. What is Collectors.teeing() method?

It is a static method introduced in Java 12, added into java.util.stream.Collectors interface which allows us to collect using two independent downstream collectors then merges their results using the specified BiFunction

Collectors_Teeing_Java12_Signature

2. How to use it?

Let’s take an example where we have a list of ‘Agents’ and we are trying to find the highest and lowest ranking agents using ‘Teeing()’ method.  

 

Agent (Pojo class):

 

Output:

 

Collectors.teeing() method in Java 12...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References:

 

Related Posts:

[wcp-carousel id=”5342″]

Promotional Content:

Loading RSS Feed

Leave a Reply

Your email address will not be published.Required fields are marked *

Facebook Twitter Instagram YouTube