Why an interface can not implement another interface?

user467871 picture user467871 · Oct 13, 2010 · Viewed 105.1k times · Source

What I mean is:

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.

However, interface is an 100% abstract class, and an abstract class can implement interfaces (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

Answer

Jigar Joshi picture Jigar Joshi · Oct 13, 2010

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

A 100% abstract class is functionally equivalent to an interface but it can also have implementation if you wish (in this case it won't remain 100% abstract), so from the JVM's perspective they are different things.

Also the member variable in a 100% abstract class can have any access qualifier, where in an interface they are implicitly public static final.