We will start with what newly introduced java.util.function and then will implement it with an example.
Java 8 introduced new package and introduced many functional interface. It can be divided into four categories.
It represents a boolean-valued function of one argument. It is a functional interface with method test(T) where T is typed.
You can see the usage here.
It represents an operation accept(T) argument of type T and return void with side-effects. Java 8 introduced many versions of Consumers.
You can see the usage of Consumer here.