In this case, I strongly recommend using the fully qualified name of the Character
class in the extends
clause.
public class Player extends characters.Character {}
Experienced Java developers know that java.lang.Character
is final
and can't thereby be extended. By writing class Player extends Character
, you would probably make them nonplussed.
Every compilation unit implicitly imports every public type name declared in the predefined package java.lang
, as if the declaration import java.lang.*;
appeared at the beginning of each compilation unit immediately after any package declaration. As a result, the names of all those types are available as simple names in every compilation unit.
Java 11 Specification > 7. Packages and Modules > 7.3. Compilation Units
Of course, it would be more reasonable to pick up a name that doesn't collide with the classes from the standard java.lang
package (like Person
, or GameCharacter
).