Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading query

 
Abhinaba Basu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps: Most specific method.
 
vidya sagar
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic