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:

Author

  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester. He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.

close

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter