Kish please Use Code Tags when you post a source code. That way your code looks formatted. Unformatted code is hard to read. You can add code tags by wrapping your code in [code] [/code] tags. You can edit your message using button and then add code tags to it...
Reference to test is ambiguous, both method test(java.lang.Integer) and method test(java.lang.Double)
Both class java.lang.Integer and java.lang.Double entends java.lang.Number directly...
so.., both methods refer to same superclass (java.lang.Number), that's why compiler tells ambiguous in that methods...
There's no error in this code because neither test method refer to same superclass..
It returns Double : null ,why?
because null boxed to Number...
please correct me if i'm wrong..
Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Double is subclass of Object so as Raju said Double is more specific than Object and will be chosen but Double and Integer both extends Number they dont have any superclass-subclass relation, Infact they both are same level classes so there is ambiguity. If you had methods with Number and Double or Integer and Double then there would be no ambiguity.
I hope I am clear.
SCJP 1.6 96%
Joined: Dec 10, 2009
If you had methods with Number and Double or Integer and Double then there would be no ambiguity.
Neha is it Number and Double or Number and Integer...........