Why can\'t I create a @FunctionalInterface
with a default method implementation?
@FunctionalInterface
public interface MyInterface {
default
That's because @FunctionalInterface
can have default methods, as many as you want. For example, consider the java.util.Function
interface. It contains two default methods: compose
and andThen
. But there should be exactly one non-default method. Otherwise how compiler would know which of your default methods should be mapped to lambda?