Possible Duplicate:
bug with varargs and overloading?
could anyone explain me how this one works:
class Vararg {
static void vararg(int... x) {
System.out.println("Integer...");
}
static void vararg(long... x) {
System.out.println("long...");
}
public static void main(String [] args) {
int s = 0;
vararg(s,s);
}
}
Get compile time error
class Vararg {
static void vararg(Integer... x) {
System.out.println("Integer...");
}
static void vararg(long... x) {
System.out.println("long...");
}
public static void main(String [] args) {
int s = 0;
vararg(s,s);
}
}
Also get compile time error. What is the mechanism when we use overloading with varargs? Is it a bug with overloading varargs methods?