Skip to content

Instantly share code, notes, and snippets.

@smamran
Last active September 22, 2015 06:26
Show Gist options
  • Save smamran/5d3d46e37cd80021a61a to your computer and use it in GitHub Desktop.
Save smamran/5d3d46e37cd80021a61a to your computer and use it in GitHub Desktop.
Java Ambiguous Function Overloading
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