views:

117

answers:

3

What I mean,

interface B;

interface A extends B; allowed  

interface A implements B; not allowed

I googled it and I found this -> Implements denotes defining an implementation for the methods of an interface. However interfaces have no implementation so that's not possible. http://www.coderanch.com/t/410331/java/java/interface-implements-interface

However, interface is 100% abstract class and abstract class can implements interface(100% abstract class) without implement its methods. What is the problem when it is defining as "interface" ?

In details,

interface A {
    void methodA();
}

abstract class B implements A {} // we may not implement methodA() but allowed
class C extends B {
   void methodA(){}
} 

interface B implements A {} // not allowed. 
//however, interface B = %100 abstract class B

Thanks

+4  A: 

implements means implementation .
Where interface is meant to declare just to provide interface not for implementation

100% abstract class is functionally equaivalent to interface but it can also have implementation if you wish(in this case it won't remain 100 %) , so from JVM prespective they are diff. thing

org.life.java
+6  A: 

implements means that you'll define a behavior for the abstract methods (or at least that you can).

extends means that you'll inherit the behavior of something else.

In the interfaces case, you can't define the behavior, but you'll clearly have the same behavior as the parent interface. That's why it's more logic for an interface to extends an interface and not implements it.

Plus remember, if an abstract class can define abstract method, working the same way methods defined in an interface do, an abstract class is by definition a class and it is totally different from an interface.

Colin Hebert
A: 

Conceptually there are the two "domains" classes and interfaces. Inside these domains you are always extending, only a class implements an interface, which is kind of "crossing the border". So basically "extends" for interfaces mirrors the behavior for classes. At least I think this is the logic behind. It seems than not everybody agrees with this kind of logic (I find it a little bit contrived myself), and in fact there is no technical reason to have two different keywords at all.

Landei