TNC*_*TNC 13 java eclipse overriding interface
我正在写各执行所谓的命令的接口,其中包含的方法的Java类isValid()
和run()
,如下所示:
public class DailyEnergy implements Command {
@Override
public boolean isValid(String command) {
return false;
}
@Override
public void run(String command) throws Exception {
}
}
Run Code Online (Sandbox Code Playgroud)
这是Command.java文件:
public interface Command {
public boolean isValid(String command);
public void run(String command) throws Exception;
}
Run Code Online (Sandbox Code Playgroud)
在这一类中,我实现了超类方法isValid()
和run()
,我想添加@Override
注释,但是Eclipse提供了一个错误,指出"该方法必须重写超类方法".
即使我拿出方法并使用Eclipse自动导入它们,如果我添加注释,我也会收到错误.如果有人能够解释为什么我不能使用@Override
注释,那将非常感激.
归档时间: |
|
查看次数: |
15767 次 |
最近记录: |