I\'m learning about Java 8 new feature Lambda expressions. This is my "HelloWorld" class using Lambda expression
public class LambdaHel
I wanted a simple local closure to pass / execute. I never found this answer anywhere, so adding my spin, so you can see actual mapping from local groovy closure to local java lambda.
Groovy:
def clos = {name -> sayHello(name)}
clos('John Doe')
Java:
Consumer clos = name -> sayHello(name);
clos.accept("John Doe");
The key being that bloody Consumer interface with accept() method to invoke - you must match the params and return type of your Java lambda based on their pre-canned Function interfaces (java.util.function.*). That bit is a drag, compared to untyped Groovy version.