Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Help coderanch get a
new server
by contributing to the
fundraiser
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Programmer Certification (OCPJP)
Method overloading with var-args
Gaurav Sahu
Greenhorn
Posts: 9
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can anybody explain why the call to the method go is not ambiguous ??
class Low { static String go(Integer x, Integer y) { return "low"; } static String go(int...x) { return "hi"; } public static void main(String args[]) { System.out.println(go(5,6)); System.out.println(go(5,6)); } }
[Added code tags - see
UseCodeTags
for details]
Helen Ma
Ranch Hand
Posts: 451
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Any overloading method with var-args is always the loser , according to KB.
So, in your case, go (int ...x) won't be chosen.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
int to string conversion using toStirng()
Calling static method from main
Question on widening ,boxing
BETA: Method resolving, un/boxing varargs mock question
static method can be inherited?
More...