i have found one strange behaviour in java. seee below code it compiles and run successfully. and prints "Integer,Integer is called" but once i commented this method i got the error on compilation saying "The method method is ambigous for the type Integer" this is because we have two method with parameters (Integer... i ) and (int... i ) but they were there earlier also (before commenting out the method (in bold) below then why i was not getting any error earlier and after commenting out the method i got.?? is it not strange.
Are you getting the error when code in bold is not commented?
Let me make more clear, see we have three methods 1st and 3rd are ambiguous but i am getting the error only when i comment the second method i am putting it again please have a look.
[ November 28, 2008: Message edited by: Tanu Gulati ] [ December 28, 2008: Message edited by: Tanu Gulati ]
Joined: Aug 05, 2008
Tanu, Looking more closely, it does seem a bit strange.
What is strange here is why the compiler allows you to declare the two methods but will only complain when you call either one. If there is a more obvious method the compiler doesn't seem to have a problem (For example int, int or Integer, Integer probably because they take exactly two parameters).
Apart from this it seems prudent for the compiler to complain that it is not sure which method to invoke. I would have liked the compiler to complain about ambiguities between the int int and Integer Integer versions too.