For the following methods:
public void test(long... l)
{
System.out.println("Widen varargs");
}
public void test(Integer... i)
{
System.out.println("Boxed and vararg'ed");
}
invocation of int i =5; test(i) will cause confusion to compiler. However if the methods are changed from varargs to normal parameters(long and Integer), then widening method will win over the Boxing parameter method. So, widening wins boxing when alone. But not when combined with var-args.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment