aspose file tools*
The moose likes Java in General and the fly likes Need clarification on overloaded method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need clarification on overloaded method?" Watch "Need clarification on overloaded method?" New topic
Author

Need clarification on overloaded method?

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163


if i call the above method using "test(null)", it is calling the method which takes String as a argument.

Can anybody explain me, how it is called?
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Java calls the method with the 'narrowest' type that you pass as an argument. String is more specific than Object.



this prints
short
short
long
long


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

This should go into the FAQ if it hasn't already, as it seems to come up quite often.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

David Newton wrote:This should go into the FAQ if it hasn't already, as it seems to come up quite often.

Its already. http://faq.javaranch.com/java/ScjpFaq#mostSpecific


http://muhammadkhojaye.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need clarification on overloaded method?