Originally posted by Ram Manoj: ... But I need what actually happens if I call test1.testMe(null)
The null literal represents the "null type." So when you use a null literal with callMe, it fails because the argument type is ambiguous. But assigning a null literal to a variable...
Object obj = null; test1.callMe(obj);
...will work, because the reference type of "obj" is Object, even though it doesn't point to an actual object.
This is essentially what's happening when you call testMe with a null literal. The null literal is assigned to the local variable 'o', and the type of 'o' is Object, so calling callMe(o) works. [ March 09, 2008: Message edited by: marc weber ]
Originally posted by Ram Manoj: ...Can you explain the following statement with an example.
In every case, when an exact match isn't found, the JVM uses the method with the smallest argument that is wider than the parameter...
In the code below, A is widest, and B, C, and D are each progressively narrower. The method is called using an instance of C. An exact match isn't found. D is narrower than C, so that method won't work. Both B and A are wider than C. But B is narrower than A, so B is invoked.
[ March 09, 2008: Message edited by: marc weber ]
Joined: Jan 12, 2008
ooh, this is it. Thankyou weber for clarifying me.
I was thinking it would be something else, the terminology got me stuck "argument that is wider than the parameter".
No more getting troubled by overloading questions.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com