/**
* 1 LambdaExpress写法:拷贝中括号,写死右箭头,落地大括号
* 2 LambdaExpress对接口的要求,接口里面的抽象方法,有且仅有一个
* 3 函数式接口才能使用Lambda写法,
* 4 新注解@FunctionalInterface
* 5 default默认实现
* 6 静态实现
*/
@FunctionalInterface
interface Foo
{
//public void sayHello();
public int add(int x, int y);
default int multi(int x, int y)
{
return x * y;
}
public static int div(int x, int y)
{
return x / y;
}
public static int div2(int x, int y)
{
return x / y;
}
}
public class LambdaExpressDemo
{
public static void main(String[] args)
{
/*Foo foo = new Foo()
{
@Override
public void sayHello()
{
System.out.println("********hello java180228");
}
};
foo.sayHello();*/
//Foo foo = () -> {System.out.println("********hello ");};
//foo.sayHello();
Foo foo = (x,y) -> {
System.out.println("*******come in add()");
return x + y;
};
System.out.println(foo.add(3,15));
}
}