Home > Java > JavaBase > body text

Can java interfaces be inherited?

(*-*)浩
Release: 2019-11-11 11:23:02
Original
7177 people have browsed it

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() {}
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template