File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

example of overloaded methods that the compiler can not resolve?

 
Rachel Glenn
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone provide to me an example of overloaded methods that the compiler finds ambiguous and is unable to resolve?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic