Java : Functional interfaces and Lamda expression
I'll show you how you can check a condition and return a boolean value. The java API includes 3 functional interfaces commonly used:
- Predicate<T>
- Consumer<T>
- Function<T, R>
The
The static method below uses the
You can use this method like this:
Thanks
Predicate
tests the T
object and returns a boolean value. The Consumer
accepts an operation on T
but does not return a value. The Function
performs an operation on T
and returns an R
object.
The static method below uses the
Predicate
interface to specify the condition:You can use this method like this:
Thanks
Comments
Post a Comment