Last active
September 22, 2015 06:26
-
-
Save smamran/5d3d46e37cd80021a61a to your computer and use it in GitHub Desktop.
Java Ambiguous Function Overloading
This file contains 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
class Main { | |
static int max(int x, double y) { | |
return (x > y) ? x : (int) y; | |
} | |
static int max(double x, int y) { | |
return (x > y) ? (int) x : y; | |
} | |
public static void main(String[] args) { | |
System.out.println(max(5, 5)); // ambiguous occurs comile time error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment