This week's giveaway is in the OCPJP forum. We're giving away four copies of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) and have Paul Anilprem on-line! See this thread for details.
I tried this code for the purpose of looking at the behavior of calling overloaded methods with a null value. But I found that when I comment the myMethod method with the String argument xor with the Integer argument I don�t get a compile time error and the program runs fine with my ambiguous call. What�s the rule on this?
If you overload myMethod(Object) with myMethod(String) and call with myMethod(null), compiler will consider myMethod(String) as more specific and call it. If you have myMethod(Integer) as well myMethod(String), they are equally specific as both extend Object directly.
[This message has been edited by rajsim (edited August 07, 2000).]
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop