@FunctionalInterface
public interface GenericFunctionalInterface {
public <T> T genericMethod();
}
I have above @FunctionalInterface and it has a generic method.
How can I use and Lambda expression to represent this Interface?
I tried below code, but it doesn't work,
GenericFunctionalInterface gfi = () -> {return "sss";};
I got compile error: Illegal lambda expression: Method genericMethod of type GenericFunctionalInterface is generic
Where can I place the type info?
<T> T geneticMethod()
promises to return whatever the caller wishes, so a lambda expression return aString
doesn’t fulfill that.