Passing a Method Reference of an Instance Method

 
friends.stream()
 
.map(​String​::toUpperCase);

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

 
friends.stream()
 
.map(name -> name.toUpperCase());

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.