[英]Class implements Interface that extends another Interface
I want to implement an interface in my class that extends from another interface, but I get the follow error: 我想在我的类中实现一个从另一个接口扩展的接口,但出现以下错误:
Class1 is not abstract and does not override abstract method method2(param1,param2) in Interface2
Class1不是抽象的,并且不会覆盖Interface2中的抽象方法method2(param1,param2)
public class Class1 implements Interface1 {
public Class1() {
//some init
}
@Override
public Object method1(Object param1) {
//some code
}
@Override
public void method2(Object param1, Object param2) {
//some code
}
}
public interface Interface1 extends Interface2 {
//some specific code
}
public interface Interface2 {
public Object method1(Object param1);
public void method2(Object param1, Object param2);
}
Why doesn't it work and what do I have to do, to make it work? 为什么它不起作用,我必须怎么做才能使其起作用?
provide the type for the parameters param1 and param2 try this 提供参数param1和param2的类型,请尝试
public class Class1 implements Interface1 {
public Class1() {
//some init
}
@Override
public Object method1(String param1) {
//some code
return null;
}
@Override
public void method2(String param1,String param2) {
//some code
}
}
interface Interface1 extends Interface2 {
//some specific code
}
interface Interface2 {
public Object method1(String param1);
public void method2(String param1,String param2);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.