Skip to content

Instantly share code, notes, and snippets.

@hnw
Created January 10, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnw/15e59a506010f604bb42 to your computer and use it in GitHub Desktop.
Save hnw/15e59a506010f604bb42 to your computer and use it in GitHub Desktop.
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