March 2019
Intermediate to advanced
242 pages
6h 21m
English
Every user-defined enum implicitly extends the java.lang.Enum class. Behind the scenes, the one-line Size enum (defined in the preceding section) is compiled into something similar to the following (I've added comments in the code to explain it; when you compile an enum, you won't get similar comments):
final class Size extends Enum // 'enum' converted to final class
{
public static final Size SMALL; // variables to store
public static final Size MEDIUM; // enum constants
public static final Size LARGE; //
private static final Size $VALUES[]; // array of all enum // constants
static
{ // static initializer
SMALL = new Size("SMALL", 0); // to initialize enum // constants MEDIUM = new Size("MEDIUM", 1); ...Read now
Unlock full access