File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Overloading query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Overloading query" Watch "Overloading query" New topic

Overloading query

Abhinaba Basu

Joined: Jun 06, 2006
Posts: 15
My code is given below:

And it is printnig "String"

And my next code is give below:

Why it is doing like this? Can anybody explain me?

<b>Abhinaba basu</b><br />Software Engineer,<br /><a href="http://""" target="_blank" rel="nofollow">Kaizen Informatics Pvt Ltd</a><br /><a href="http://""" target="_blank" rel="nofollow">My site</a> | <a href="http://""" target="_blank" rel="nofollow">My Blog</a> | <a href="http://""" target="_blank" rel="nofollow">My office</a>
marc weber

Joined: Aug 31, 2004
Posts: 11343

See if this helps: Most specific method.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Normally in this scenario,More appropriate matching method will be called.

In the First Case,String is more appropriate. so the method with string argument is called.

But in the Second Case,String and StringBuffer is in same level so the compiler cannot know which one to choose.So it throws ambiguous error.
I agree. Here's the link:
subject: Overloading query
It's not a secret anymore!