介绍:
函数式接口定义:一个接口有且只有一个抽象方法
函数的方法是:返回值 方法名 参数列表 方法体
Lambda表达式本质是一个匿名函数 只需要注意:参数列表 方法体。
1.无参数 无返回值
接口
interface If1{
void test();
}
2.有两个参数
接口
interface If1{
void test(int a,int b);
}
3.无参数有返回值
interface If1{
int test();
}
4.有参数有返回值
interface If1{
int test(int a);
}
简化方法 :(不详细介绍了)
1.省参数类型
2.如果只有一个参数 ()可以省略
3.如果方法体只有一条语句 { }可以省略
4.如果方法体唯一的语句是 return返回语句 那省略{ }时 return也必须省略