为什么我们需要在实现FunctionalInterface时编写“implements FI”?为什么我们需要在实现功能接口时编写“implements InterfaceName”?
@FunctionalInterface
interface FI
{
void sayHello(String name);
}
public class Hello implements FI
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
FI fi = (name) -> System.out.println("Hello " + name);
fi.sayHello("world");
}
}
你不需要它([证明](https://ideone.com/5gZge4))。你的代码甚至不会编译,因为你的类'Hello'没有实现'FI'的'sayHello'方法。投票不可重复。 – dasblinkenlight
你的代码确实不会编译([proof](https://ideone.com/dj0Bl3))。 –