This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Widening, boxing with var-args and overloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Widening, boxing with var-args and overloading" Watch "Widening, boxing with var-args and overloading" New topic
Author

Widening, boxing with var-args and overloading

Andry Dub
Ranch Hand

Joined: Nov 06, 2007
Posts: 43
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");
}
}


Java is my love
Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
The same topic was just covered here:

http://www.coderanch.com/t/266522/java-programmer-SCJP/certification/Overloaded-varargs-param


SCJP 5.0
Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
The same topic was just covered here:

http://www.coderanch.com/t/266522/java-programmer-SCJP/certification/Overloaded-varargs-param
 
Don't get me started about those stupid light bulbs.
 
subject: Widening, boxing with var-args and overloading
 
Similar Threads
widening,boxing and var args??
Widening,Boxing and Var-Args Combined
Overloading with varargs
Widening
var-args and overloading