I just tried the following programs.I am using netbeans.
public static void main(String[] arguments)
{
int var = 24;
method1(var);
}
//Overloaded methods are
public static void method1(int var)
{
System.out.println(var+"hi");
}
public static void method1(long var)
{
System.out.println(var+"bye");
}
When i execute it , there is an exact match for int. So it prints 24hi.
public static void method1(int... var)
{
System.out.println(var+"hi");
}
public static void method1(long... var)
{
System.out.println(var+"bye");
}
Now method overloading with variable length arguments. But it shows an error due to ambiguity. Why so?? My doubt is that there is an exact match here also. Why it falls into ambiguity here? Any suggestions?