• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Ambiguity in overloaded methods

 
Ranch Hand
Posts: 330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
I'm getting an ambigous compile-time error on line 5 of the code below. The method being invoked is supposedly an inherited method from Base1. Class Derived1 contains an overloaded version of this method. Compiling the code results in an ambiguous error. That's all good but what I dont understand is that class Temp also contains the same overloaded methods and I can invoke the int version without any ambiguity.
I would appreciate some enlightenment from anyone here. Thanks.
Kung Hei Fat Choi to Chinese Ranchers!

 
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May I know the version of your compiler? I believe it has something to do with the way the compiler handles the 'most specific method'. There had been some changes in the JLS regarding this issue and your compiler may not be up-to-date.
My compiler's version is 1.4.2 and compiles fine. And if I run it, the output is 3 3.
 
dennis zined
Ranch Hand
Posts: 330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alton.
Couple of things:
- I have java version 1.4.2_03 and its the only one on my machine.
- I always use eclipse to compile and run my code. Version of eclipse is 2.1.2. I configured eclipse to use the installed jdk 1.4.2_03.
Steps I took after reading your post:
- Compiled and ran the code outside eclipse (used notepd). Compiler is still the alredy installed jdk 1.4.2_03
- Code compiled and ran fine!
So I'm arriving at a conclusion that this might be an IDE problem? But the IDE is using jdk 1.4.2_03?
Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic