March 2019
Intermediate to advanced
242 pages
6h 21m
English
Let's cover the existing issues with resolving overloaded methods when lambdas are passed as method parameters. Let's define two interfaces, Swimmer and Diver, as follows:
interface Swimmer { boolean test(String lap);}interface Diver { String dive(int height);}
In the following code, the overloaded evaluate method accepts the interfaces Swimmer and Diver as method parameters:
class SwimmingMeet { static void evaluate(Swimmer swimmer) { // code compiles System.out.println("evaluate swimmer"); } static void evaluate(Diver diver) { // code compiles System.out.println("evaluate diver"); }}
Let's call the overloaded evaluate() method in the following code:
class FunctionalDisambiguation ...
Read now
Unlock full access