java.util.function.Function is a functional interface as part of java.util.function package which is introduced in Java 8. It is an in-built Functional Interface. This function expects one argument and produces a result. In this post, we are going to see several implementations of Function Interface using different examples.

java.util.function.Function Interface in Java 8 with Examples...!!! Click To Tweet

Look at java.util.function.Function Javadoc description below:


Function Interface contains 4 methods:

  1. apply

  2. compose

  3. andThen

  4. identity

Lets understand above mentioned methods thorough various examples:

Example 1. ‘apply’ method

Below example shows how to use ‘apply’ method of ‘Function’ interface using Lambda expression.


Example 2. ‘andThen’ & ‘compose’ methods

Below example shows how to use ‘andThen’ & ‘compose’ methods of ‘Function’ interface using Lambda expression.


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

Other Useful References:


  • 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.