Why does Java allow to implement different interfaces, each containing a method with the same signature?

Posted by Software Engeneering Learner on Programmers See other posts from Programmers or by Software Engeneering Learner
Published on 2012-11-28T11:29:36Z Indexed on 2012/11/28 17:18 UTC
Read the original article Hit count: 324

Filed under:
|

I've recently found that I can have two interfaces containing method with the same signature as a method in the other interface. And then I can have an interface or class that implements both of that interfaces. So the descendant class/interface has implicitly implements two different methods as a one method.

Why is this allowed in Java?

I can see a numerous problems that arises from that. Even eclipse only can find out about implementations for only one interface method, but for the second one it doesn't show any implementations at all. Also I believe there would be problems with automatic refactoring, like when you would like to change the signature of the method in one of the interfaces and IDE won't be able to correctly change that signature in all implementations, as they implement two different interfaces and how will IDE know what interface method it implementation descends.

Why don't just make a compiler error like 'interfaces method names clashes' or something like that?

© Programmers or respective owner

Related posts about java

Related posts about inheritance