General Purpose Functional Interfaces in Java 8

Java 8 introduces few general purpose functional interfaces based on the input and output to the single abstract method.

 

Most common ones are:

  1. Predicate<T> whose method

    1. takes in an argument of type T and

    2. rerturn a boolean.

  2. Consumer<T> whose method

    1. takes in an argument of type T and

    2. rerturn nothing (void).

  3. Function<T,R> whose method

    1. takes in an argument of type T and

    2. rerturn type R.

  4. Supplier<T> whose method

    1. takes no arguments and

    2. rerturn type T.

  5. UnaryOperator<T> whose method

    1. takes in an argument of type T and

    2. rerturn type T.

  6. BinaryOperator<T,T> whose method

    1. takes in an argument of type (T,T) and

    2. rerturn type T.

 

TODO

Provide sImple examples for each of these.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!