Following program prints Object
as output, and when I remove the overloaded method contains Object
as parameters, following compile time error is there:
The method m1(Long) in the type LangPackage is not applicable for the arguments (int)
public class A {
public static void main(String args[])
{
int x = 0;
m1(x);
}
static void m1(Long l) {
System.out.println("long");
}
static void m1(Object l) {
System.out.println("Object");
}
}
My query is why auto-boxing
followed by widening is allowed for Objects
not for Long
type