This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ambigious Interface solution?

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3159
33
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And always better to avoid Ambiguous situations.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry people please don't go on syntax....it was not copy paste i just typed it here...
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roberto now my doubt has been cleared
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic