由此我们可以得出编译以后的代码为:
public class LambdaTest {public static void main(String[] args) {
Func func= LambdaTest$$Lambda$1();
System.out.println(func.add(1, 2));
}
private static int lambda$main$0(int x, int y) {
return x + y;
}
static final class LambdaTest$$Lambda$1 implements Func {
private LambdaTest$$Lambda$1() {
}
public int add(int x, inty) {
return LambdaTest.lambda$main$0(x,y);
}
}
}
总结下,Lambda底层就是通过一个静态的内部类实现的;
结尾