This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt related to var-args 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 "Doubt related to var-args" Watch "Doubt related to var-args" New topic

Doubt related to var-args

Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
In case we try to define overloaded method that take wrapper class var-args as well as primitive type var-args , we can't not pass either single primitive or single wrapper at time of method call.. What does it mean?


what if i want to make this code error free without doing any change to both "public static void callMethod()" .
Abhinav Shukla

Joined: Jul 18, 2011
Posts: 13

Compiler cant choose between primitive and boxed type if combined with varargs.

To be more general, 'varargs primitive', 'varargs + boxed primitive' and 'vargs + widened primitive' are consindered same; and are not legal for overloading.

Example : int.. , long... and Integer... are one and same and give error when used for overloading.
Have you checked out Aspose?
subject: Doubt related to var-args
It's not a secret anymore!