public class test {
test(double[] a)
{
System.out.println("in double");
}
test(Object a)
{
System.out.println("in object");
}
public static void main(String args[])
{
new test(null);
}
}
In the above code, I pass null
as the constructor argument. As null
can be anything, the above code compiles fine. When I run the code I expected it to print in object but it prints in double
What is the reason behind this?
NOTE the linked question may not be duplicate because this question is related with primitive datatype vs Object