This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes example of overloaded methods that the compiler can not resolve? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "example of overloaded methods that the compiler can not resolve?" Watch "example of overloaded methods that the compiler can not resolve?" New topic
Author

example of overloaded methods that the compiler can not resolve?

Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
Can someone provide to me an example of overloaded methods that the compiler finds ambiguous and is unable to resolve?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4396
    
    8

The trick is to have two arguments, where one is more specific in one method, and the other is more specific in the other. Try this, for example (I haven't tested it, but it should "work"):


The compiler is fine until you try to call the methods with arguments that could work for both.
 
GeeCON Prague 2014
 
subject: example of overloaded methods that the compiler can not resolve?