How to pass a Java 8 lambda with a single parameter
问题 I want to simply pass a lambda (chunk of code) and execute it when I need to. How do I implement the method executeLambda(...) in the code below (as well what is the method signature): public static void main(String[] args) { String value = "Hello World"; executeLambda(value -> print(value)); } public static void print(String value) { System.out.println(value); } public static void executeLambda(lambda) { someCode(); lamda.executeLambdaCode(); someMoreCode(); } 回答1: Your lambda takes one