Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Ambiguous Method

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Why is this method giving ambiguous error while compiling?


I know that ambiguous problem occur if the parameters of the method is like:

public int area(int length , long width){}

public int area(long length , int width){}

But why in this question as they are completely diffrent from the other overloaded method?

Thanks
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sandhi mridul:
...Why is this method giving ambiguous error while compiling?...


This code compiles fine for me. The output is 20.
 
sandhi mridul
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for answering Marc.

But the above code is giving error as: "The method area(long,long)is ambiguous for type square".

I tried this program again but still the same answer ambiguous.
[ February 29, 2008: Message edited by: sandhi mridul ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you doing a clean build every time?
Are you deleting all of your class files before recompiling?
 
    Bookmark Topic Watch Topic
  • New Topic