没有类型的Lambda表达式 [英] Lambda Expression without types
本文介绍了没有类型的Lambda表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我了解Java8 lambda表达式的语法,但是为什么下面的代码在没有x的特定类型声明的情况下可以工作?为什么打印"baz"?
I understand the syntax of the Java8 lambda expressions but why does the following code work without a specific type declaration of x? Why is "baz" being printed?
public class LambdaExpressions {
interface Foo {
void bar(Object o);
}
static void doo(Foo f) {
f.bar("baz");
}
public static void main(String[] args) {
doo( x -> {System.out.println(x);});
}
}
推荐答案
查看全文