|
Re: Problem in Core Java
|
Posted: Sep 2, 2002 12:19 PM
|
|
It is because Java finds two methods matching null argument: 1. IT is String arg 2. It is Object arg
Now Java will choose which one is more specific and it finds that String argument method is more specific and that is why it calls that methods always. To find that which method is more specific, you can try to call other method from within the body of other one and see if it is possible. Object is not always a String, however a String is always an Object. So String version of method argument is more specific. Also, refer to JLS for more details on this topic. Here, null can be assigned to String as well as Object. However, String can also be assigned to Object and not vice versa.
Thanks Kishori
|
|