File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Ambigious Interface solution? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Ambigious Interface solution?" Watch "Ambigious Interface solution?" New topic
Author

Ambigious Interface solution?

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270



The above code creates an ambigious situation for the class .... it complies sucessfully but bot return any value..Anyone please tell me why it happen so ... and if i want to remove this ambiguity what I have to do?

Thanks
Kaustubh


No Kaustubh No Fun, Know Kaustubh Know Fun..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Kaustubh G Sharma wrote:it complies sucessfully

No it doesn't. When I compile it:

and if i want to remove this ambiguity what I have to do?

Since both a.x and b.x are public static final you can use those names: a.x and b.x.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14107
    
  16

That code doesn't compile at all.

You wrote "Interface" and "Class" with capital letters in lines 1, 6 and 10, and you can't put a System.out.println(...); statement at class level, as you are doing in line 11.

Please PostRealCode, not pseudo-code that doesn't really work, because that will confuse the question. It's important to be precise.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Uhm yeah. I fixed those issues already when trying, but Jesper is right. We should be able to copy-paste your code and try for ourselves without having to fix any issues that you don't have (like fixing the issues Jesper mentioned).
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

And always better to avoid Ambiguous situations.


Mohamed Sanaulla | My Blog
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Rob Prime wrote:
Kaustubh G Sharma wrote:it complies sucessfully

No it doesn't. When I compile it:



Sorry Boss My mistake it is also not compiling at my side also...I got ambiguity in words also...
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Sorry people please don't go on syntax....it was not copy paste i just typed it here...
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2264
    
    3

Howdy, Kaustubh!

Champ, look at what Rob said: "Since both a.x and b.x are public static final you can use those names: a.x and b.x.". This solves your problem.

Other than that, you have an instruction (System.out.println(x)) in a place of the class where it is not expected. You can put it in a static block:



or in a method:



Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

Thanks Roberto now my doubt has been cleared
 
jQuery in Action, 2nd edition
 
subject: Ambigious Interface solution?