接口可以在Java中扩展多个接口吗? [英] Can an interface extend multiple interfaces in Java?
本文介绍了接口可以在Java中扩展多个接口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
接口
可以在Java中扩展多个接口吗?
Can an interface
extend multiple interfaces in Java?
推荐答案
是的,你可以做到。接口可以扩展多个接口,如下所示:
Yes, you can do it. An interface can extend multiple interfaces, as shown here:
interface Maininterface extends inter1, inter2, inter3 {
// methods
}
单个类也可以实现多个接口。如果两个接口有一个定义相同名称和签名的方法怎么办?
A single class can also implement multiple interfaces. What if two interfaces have a method defining the same name and signature?
有一个棘手的问题:
interface A {
void test();
}
interface B {
void test();
}
class C implements A, B {
@Override
public void test() {
}
}
然后单个实现适用于:)。
Then single implementation works for both :).
在这里阅读我的完整帖子:
Read my complete post here:
http://codeinventions.blogspot.com/2014/07/can-interface-extend-multiple.html
这篇关于接口可以在Java中扩展多个接口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文