wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes VarArgs 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 "VarArgs" Watch "VarArgs" New topic
Author

VarArgs

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, Could you please let me know why I am not able to call these methods & how I can call these methods.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
I had a similar problem: var-args overloading compiler error: ambiguous and the problem went away when I upgraded to the latest Java version.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3056
    
  33

Tom Reilly wrote:I had a similar problem: var-args overloading compiler error: ambiguous and the problem went away when I upgraded to the latest Java version.


I think both are different issues. In this questions the ambiguity is due to- Either use the int version or to autobox to use the Integer version.


Mohamed Sanaulla | My Blog
ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160

Integer... and int... both are considered as arrays and there is no way to compare this two arrays for compiler. so that when it finds any integer parameter passed into method at that compiler checks both version of method if the argument passed can satisfy the requirement and here in this case it finds that both methods are eligible to run so that compiler gets confused which method to call. Therefore it gives ambiguity error......

if there would be Long and Integer parameters in the methods then compiler can easily find out that which method to call because compiler can differentiate them .........


OCPJP(83%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: VarArgs
 
Similar Threads
varargs overloaded method
overloading
Var-args and method overloading doubt
Overloading (primitive/Wrapper) var-arg methods
Widening, boxing with var-args and overloading