Returning a Lambda Expression
| public static Predicate<String> checkIfStartsWith(final String letter) { |
| return name -> name.startsWith(letter); |
| } |
If a method’s return type is a functional interface, we can return a lambda expression from within its implementation.
Get Functional Programming in Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.