下面哪些接口是函數(shù)式接口癌瘾?
public interface Adder{
int add(int a, int b);
}
public interface SmartAdder extends Adder{
int add(double a, double b);
}
public interface Nothing{
}
答案:只有Adder是函數(shù)式接口俯在。
SmartAdder不是函數(shù)式接口房交,因?yàn)樗x了兩個(gè)叫作add的抽象方法(其中一個(gè)是從Adder那里繼承來(lái)的)徐绑。Nothing也不是函數(shù)式接口,因?yàn)樗鼪]有聲明抽象方法忌穿。
來(lái)源:java8實(shí)戰(zhàn)