Created
June 25, 2012 15:37
-
-
Save jartur/2989312 to your computer and use it in GitHub Desktop.
java8 lambda overloading example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Wewe { | |
interface A { | |
int run(int x); | |
} | |
interface B { | |
int run(String x); | |
} | |
private void overloaded(A a) | |
{ | |
a.run(1); | |
} | |
private void overloaded(B b) | |
{ | |
b.run("1"); | |
} | |
private void a() | |
{ | |
overloaded(x -> {return 1;}); | |
// error: reference to overloaded is ambiguous, both method overloaded(A) in Wewe and method overloaded(B) in Wewe match | |
overloaded((A)x -> {return 1;}); | |
// OK | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment