Skip to content

Instantly share code, notes, and snippets.

@deepakmehra10
Created July 14, 2019 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakmehra10/e60b5238e9c982f0e8e30a53c71d28c8 to your computer and use it in GitHub Desktop.
Save deepakmehra10/e60b5238e9c982f0e8e30a53c71d28c8 to your computer and use it in GitHub Desktop.
Function1<Integer, Integer> incrementOne = number -> number + 1;
Function1<Integer, Integer> incrementTwo = number -> number + 2;
//with andThen function
Function1<Integer, Integer> resultantFunction = incrementOne.andThen(incrementTwo);
System.out.println(resultantFunction.apply(5));
//with compose function
Function1<Integer, Integer> resultantFunctionWithCompose = incrementOne.compose(incrementTwo);
System.out.println(resultantFunctionWithCompose.apply(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment