"Cannot subclass the final class" error, but the class is not final

Fletcher :

Here is my code:

package basic;

public abstract class Entity {}

package characters;

import basic.Entity;

public abstract class Character extends Entity {}

package player;

public class Player extends Character {}

I am getting the

The type Player cannot subclass the final class Character.

but I checked a million times and I am yet to use final all but ONCE in my project. What gives?

Adam Kotwasinski :

You are extending java.lang.Character (which does not need an import, as it comes from java.lang).

Insert import characters.Character into your Player code.


Reference: using package members:

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).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=35191&siteId=1
Recommended