Reference 55049192
This explains why an enumeration class cannot be inherited: it has inherited the parent enum class, and its parent implements the serializable interface, which means that all enum classes implement serialization
The Enum class also cannot be inherited for the following reasons:
The public enum class name {variable list is separated by commas, and the last variable ends with a semicolon; List of available functions}
In fact, the enumeration class itself is the public final class enum class name {The type of the variable list is that class type and also uses the final keyword}, and the enumeration class comes with the declaration/definition of the value (), the valueof () function, and the static{} static code block.
So variables in the variable list can be written in three ways: 1. Variable name. Equivalent to defining a static variable with an enumeration class type
2. Variable name (variable name corresponds to value). A variable is defined with an enumeration class type, but the enumeration class has a private parameter constructor method and a private variable to use as a parameter, and the value of the parameter is the value of the variable name.
3. Variable name (variable name corresponding value) {Static code block}//except 2, the enumeration class also defines an abstract method, and the code block after the variable name corresponds to an anonymous inner class that implements the abstract method. As follows: Variable type variable name =new Enum class class name (parameter) {@Override
Public enum class type abstract class class name () {
return variable name;}
}
Java enum class enum, defining static variables can also have abstract methods, but enum classes cannot be inherited