Calling a Method with Mixed Parameters

 
friends.stream()
 
.reduce(​"Steve"​, (name1, name2) ->
 
name1.length() >= name2.length() ? name1 : name2);

Methods can have a mixture of regular classes, primitive types, and functional interfaces as parameters. Any parameter of a method may be a functional interface, and we can send a lambda expression or a method reference as an argument in its place.

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.