Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

VarArgs

 
Saibabaa Pragada
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ankur trapasiya
Ranch Hand
Posts: 160
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .........
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic