
在Java中,一个接口不能实现另一个接口。
interface MainInterface {
void mainMethod();
}
interface SubInterface extends MainInterface { // If we put <strong>implements </strong>keyword in place of <strong>extends, </strong>// compiler throws an error.
void subMethod();
}
class MainClass implements MainInterface {
public void mainMethod() {
System.out.println("Main Interface Method");
}
public void subMethod() {
System.out.println("Sub Interface Method");
}
}
public class Test {
public static void main(String args[]) {
MainClass main = new MainClass();
main.mainMethod();
main.subMethod();
}
}Main Interface Method Sub Interface Method
以上就是为什么在Java中一个接口不能实现另一个接口?的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号