This will not compile:
public class Methods
{
public static void method(Integer... i)
{
System.out.print("A");
}
public static void method(int... i)
{
System.out.print("B");
}
public static void main(String args[])
{
method(7);
}
}
This will compile and work:
public class Methods
{
public static void method(Integer i)
{
System.out.print("A");
}
public static void method(int i)
{
System.out.print("B");
}
public static void main(String args[])
{
method(7);
}
}
First and second example are very similar. First uses varargs, second not. Why one works, second not. 7 is primitive, so second method should be called in both cases. Is it normal behaviour?
I found it: Bug report Stack overflow