• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Wrapper (not Rapper) class need help!!

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Okay! Figure out the output when we try to compile and run this code!
Can anyone explain why we got output like that?
[ August 14, 2007: Message edited by: fedry kemilau ]
 
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A very similar problem is already discussed here
 
Fedry Kemilau
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you

This post can be deleted now.
 
Abdullah Mamun
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My plesure
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey Fedry...

your code is good.. thats a trick question...

now lets analyze the situation....

you have declared a single method twice(which you can i.e., using overloading) with the same name, return type and almost of a single type of parameter...i.e., var-args..
however the parameters differ in being a Long and an Integer...

this looks like you have overloaded the method and think that the compiler is still complaining about its structure....
here's the problem....

you have declared a single method twice .....
with ...
same name..
same return type... and ...
parameters of same type(var args).
however these differ in being two different subtypes of varargs...
one being the Long type and
the second being of the Integer type...

Both are wrapper types... or.. you can say both are Basically varargs...

BUT THE PROBLEM is that you can't define a single method twice with the same name, same return type and same type of parameters...varargs...
i.e., the same signature....

you can define a single method twice with the same name...

BUT... with different parameters, different return types...while different parameter's being MUST....

this is what the compiler is worried about.. and thats why it has thrown an error..

saying that the call is for a method that has been declared ambiguous..

so...is your question javascript: x()
bangheadanswered..javascript: x()
jumpingjoy

if you have any doubts regarding this you can email me...ok... bye...
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sandeep, the two method definitions do have different parameter types. Let's not repeat all this discussion here again. The post that Al Mamun pointed to, here, is virtually the exact same code. The method and class names are different, but the reason the compiler complains of ambiguity is the same.

Fedry, where is this code coming from? Why do we have several people posting nearly the same code? Is there a mock exam out there which includes this problem?
 
Fedry Kemilau
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not from mock exams. I just code to try any possibility.
 
permaculture is largely about replacing oil with people. And one tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic