Let's look at the lambda
invoke(() -> "done");
The fact that you only have
"done"
makes lambda compatible. A lambda body that does not look executable implicitly becomes
{ return "done";}
Now, since Runnable#run() has no return value, and Callable#call() is the last one to be selected.
Say what you wrote
invoke(() -> System.out.println());
instead, the lambda will be resolved to an instance of type Runnable , since there is no expression that could use the return value.
source share