File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Widening, boxing with var-args and overloading

 
Andry Dub
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I wonder, why this code has a compiler error (ambiguous method call). Doesn't widening beat boxing?

public class Pennard {
public static void main(String argv[]) {
Pennard p=new Pennard();
int d=7;
p.doit(d,d); <-compile error here
}
public void doit(long...x){
System.out.println("long...x");
}
public void doit(Integer...x){
System.out.println("Integer...x");
}
}
 
Joshua Fix
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same topic was just covered here:

http://www.coderanch.com/t/266522/java-programmer-SCJP/certification/Overloaded-varargs-param
 
Joshua Fix
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same topic was just covered here:

http://www.coderanch.com/t/266522/java-programmer-SCJP/certification/Overloaded-varargs-param
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic