I just started learning Java's functional programming, and got really confused why the class implementation could work but the lambda expression won't in the following expression (I know the way to add the generic to the function is kind of silly, but its for learning purpose). Can anyone help?
@FunctionalInterface
interface Applier {
<A> void apply(A a);
}
@FunctionalInterface
interface Getter {
<V> V get();
}
public class Main {
public static void main(String[] args) {
Applier nonDoer = TestImpl::apply; //works
Getter nonGetter = TestImpl::get; //works
Applier lambdaApply = (Object o) -> {}; // does not work
Getter lambdaGet = () -> null; // does not work
}
}
class TestImpl {
static void apply(Object O) {
}
static <V> V get() {
return null;
}
}