wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes One class implement two interfaces with common methods?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "One class implement two interfaces with common methods??" Watch "One class implement two interfaces with common methods??" New topic
Author

One class implement two interfaces with common methods??

Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
Two interfaces have same methods.
one class implements both interfaces.
Is any problem in this? How will we distinguish the methods?
Albin Joseph
Greenhorn

Joined: Jan 22, 2005
Posts: 21
No problem.

Why you need to distingush methods from these two interfaces ? Because there is no implementation in the interface so would it make any sense distingushing these two itnerfaces.


Java source code examples | Java coding community.
Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
But .NET is distinguishing why?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
No idea about .NET ... does the method implementation specify which interface it is for? But in Java the logic is fairly simple.

Interface A says the implementer must have method x(). Interface B says the implementer must have method x(). If you have method x() the syntax is good and you have satisfied the compiler's checking for both interfaces.

If the documentation for interface A says x() increments the x coordinate and the doc for B says it decrements the x coordinate, the semantics are inconsistent and some client of your class will be unhappy.

So there can be cases where implementing two interfaces with matching method signatures is possible, but not correct. If .NET matches the method implementation to the interface they might get around this issue.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One class implement two interfaces with common methods??
 
Similar Threads
implementing two interfaces with the same method name!
HOW TO IMPLEMENT TWO SAME METHODS FROM DIFFERENT INTERFACES IN ONE CLASS
how to implement two interfaces having same methods
Two interfaces are having the same method....
member interfaces