Having discussed the nature of functions in Java 8, we will now focus on the various ways in which functions can be composed. By compose, we mean how they can be combined in interesting and powerful ways. These techniques include basic function composition and the use of fluent interfaces.
Function composition is concerned with combining two functions to form a third one. Using the output of one function as the input to another one is a common practice. By combining two such functions, we are able to create more complex functions, which can be reused.
We will examine the basic approach for composing functions and then move on to the use of the
Function interface and its
andThen methods. ...