When I run this code with two different varargs (Integer...i) and (int...i), the output of code with (Integer...i) displayed warning message and the other was run correctly. But I cannot understand the different between them.
public static void test(Integer...i) {
System.out.println("int array");
}
public static void main(String[] args) {
test(null);
}
When run this code, warnings message display like that.
File.java:11: warning: non-varargs call of varargs method with inexact argument type for last parameter;
test(null);
^cast to Integer for a varargs call
But when I change varargs (Integer...i) to(int...i), code was run perfectly.
public static void test(int...i) {
System.out.println("int array");
}
public static void main(String[] args) {
test(null);
}
And output display is:
int array