Created
January 10, 2015 06:19
-
-
Save hnw/15e59a506010f604bb42 to your computer and use it in GitHub Desktop.
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
public class Overload{ | |
public static void foo(int x){ | |
System.out.println("int"); | |
} | |
public static void foo(double x){ | |
System.out.println("double"); | |
} | |
public static void foo(int... x){ | |
System.out.println("int..."); | |
} | |
public static void foo(double... x){ | |
System.out.println("double..."); | |
} | |
public static void main(String[] args) { | |
int i =1; | |
int j =127; | |
foo(i); // "int" | |
foo(i, j); // ambiguous on JDK6 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment