Cannot convert functional interface with generic method into lambda expression.
Following code is working. It is without lambda expression i.e. using anonymous class.
public interface Pro{
public <T> void callee(T t);
}
public void fun(Pro obj){}
public void implement() {
fun(new Pro() {
@Override
public <Integer> void callee(Integer t){}
});
}
I cannot understand how to use lambda expression instead of anonymous class.
After trying it myself I used the hint shown in netbeans. I used the shown bulb to do it.
And here is what I got, an ERROR.
public void implement() {
fun((Integer t) -> {
});
}
It is showing error. What is the correct lambda expression to be used here?
Here is the error :
one\LambdaScopeTest.java:18: error: incompatible types: invalid functional descriptor for lambda expression
fun((Integer t) -> {
^
method <T>(T)void in interface Pro is generic
where T is a type-variable:
T extends Object declared in method <T>callee(T)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get
full output