x-special/nautilus-clipboard
copy
file:///home/aaa/Pictures/Screenshot%20from%202021-08-05%2000-21-34.png
这是别人写的Java项目。
其中多次直接使用接口名(ICommand),如List<接口名>。项目运行时的报错也与此相关,都是运行到接口中声明的方法时报错。
x-special/nautilus-clipboard
copy
file:///home/aaa/Pictures/Screenshot%20from%202021-08-05%2000-31-57.png
整个项目中只出现过一个类AbstractCommand实现了接口。
第一次使用接口名的语句是:List<ICommand> commands = new ArrayList<>();
而且语句List commands = new ArrayList<AbstractCommand>();报错
请问这种使用接口的方式对吗,报错产生的原因可能是什么,针对上面这句初始化应该怎么改?