Passing a Method Reference to a static Method

 
str.chars()
 
.filter(​Character​::isDigit);

We can replace a lambda expression with a method reference if it directly routes the parameter as an argument to a static method. The preceding sample code is equivalent to this:

 
str.chars()
 
.filter(ch -> ​Character​.isDigit(ch));

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.