Storing a Lambda Expression

 
final​ ​Predicate​<​String​> startsWithN = name -> name.startsWith(​"N"​);

To aid reuse and to avoid duplication, we often want to store lambda expressions in variables.

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.