Home  >  Article  >  Java  >  Can java interfaces be inherited?

Can java interfaces be inherited?

(*-*)浩
(*-*)浩Original
2019-11-11 11:23:027170browse

Can java interfaces be inherited?

#Java interfaces can be inherited, and it is multiple inheritance, but only interfaces can inherit interfaces, and classes can only implement interfaces. An interface can inherit another interface or multiple interfaces, and a common class can implement multiple interfaces.

Specific code: (Recommended learning: java course)

interface A{
    void a1();
}
 
interface B{
    void b1();
}
 
interface C extends A,B{//注意该语法只对接口的继承是合法的
    void c1();
}
 
class D implements C{
 
    @Override
    public void a1() {}
 
    @Override
    public void b1() {}
 
    @Override
    public void c1() {}
}

The above is the detailed content of Can java interfaces be inherited?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:how to run javaNext article:how to run java