Doug Gunnoe
Posts: 22
Nickname: dgun
Registered: May, 2007
|
|
Re: when "null" is used in an overloaded method, most specific method is called
|
Posted: Jun 13, 2007 3:36 AM
|
|
I looked here http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html at 15.12.2.2, but did not find an answer I liked. You may have better luck.
Now I will take a wild guess, which will probably not help you very much, which probably does not matter anyway since you asked this question 2 weeks ago:
In evaluating the two methods and trying to determine which one is more specific, java compares the null reference to both objects "b" and "a" in the param list of the similarly named methods meth1, which could apply to either. However, since "b" (as a subclass) is also an "a" (and not the other way around) the method that takes the "b" wins.
|
|