Hi Babu,

I once read this article about overloading behaviour on passing 'null'
as argument.
This is a good article that helps you understand how this happens and what the
Java Language specification has to tell about this :
http://geekexplains.blogspot.com/2009/06/choosing-most-specific-method-tricky.html

Thanks,
Ashok A V

On Tue, Aug 4, 2009 at 1:06 PM, Babu Rajendran<oakdevelo...@gmail.com> wrote:
> Hi All,
>
> Can somebody explain me this behaviour? The output of the code below gives
> me null. When I ran it through the Debugger I found that the String version
> of method is executed. But why isn't the object version not executed? How
> does the compiler decide this ?
>
> class Test
> {
>     public static void main(String[] args)
>     {
>         Test test = new Test();
>         test.method(null);
>     }
>     void method(String str)
>     {
>         System.out.println(str);
>     }
>     void method(Object obj)
>     {
>         System.out.println(obj);
>     }
> }
>
> Regards,
> Babu
>
> >
>



-- 
Victory belongs to the most persevering.
 - Napoleon

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to