这是我的代码:
package basic;
public abstract class Entity {}
package characters;
import basic.Entity;
public abstract class Character extends Entity {}
package player;
public class Player extends Character {}
我收到了
The type
Player
cannot subclass thefinal class Character
.
但我检查了一百万次,我还没有在我的项目中使用 final
一次。什么给了?
最佳答案
您正在扩展 java.lang.Character
(不需要导入,因为它来自 java.lang
)。
将 import characters.Character
插入到您的 Player
代码中。
For convenience, the Java compiler automatically imports two entire packages for each source file: (1) the java.lang package and (2) the current package (the package for the current file).
关于java - "Cannot subclass the final class"错误,但类不是最终的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779769/