Slides Lambda Expressions Functional Interfaces and Method References Java's Functional Interfaces Consumer & Predicate
Slides Lambda Expressions Functional Interfaces and Method References Java's Functional Interfaces Consumer & Predicate
function
On this slide, I'm showing the two most common Consumer interfaces, and the functional
method on each.
The Consumer interface takes one argument of any type.
The BiConsumer interface takes two arguments, of two different types.
Interface Name Method Signature
Consumer
BiConsumer
This slide shows an example consumer lambda expression. It takes one argument and
executes a single statement.
No result is returned.
The predicate interfaces take one or two arguments, and always returns a boolean value.
They are used to test a condition, and if the condition is true, some operation will be
performed.
BiPredicate
In this example, the expression takes a String, and tests if it's equal to the literal text, “Hello”
here, ignoring case, so it returns either true or false.