Quantcast
Channel: Choosing between overloaded methods if actual parameter is a lambda - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by biziclop for Choosing between overloaded methods if actual...

Although @thecoop's answer is correct, there is another aspect of the lambda mechanism worth mentioning. Lambdas with block bodies fall into two categories: void-compatible and value-compatible. The...

View Article


Answer by thecoop for Choosing between overloaded methods if actual parameter...

I believe this is because Callable declares a return type, and Runnable does not. From the JLS section 15.12.2.5, the overload with the most specific type is chosen, if there is one unambiguously most...

View Article


Choosing between overloaded methods if actual parameter is a lambda

In Java 1.8, the following lambda expression complies with both Runnable and Callable functional interfaces: () -> { throw new RuntimeException("FIXME"); } Still, if I submit it to an...

View Article
Browsing latest articles
Browse All 3 View Live