March 2019
Intermediate to advanced
242 pages
6h 21m
English
At present, an enum constant can access the following:
For the Size enum (defined in the preceding section), you can access the state and behavior common to all enum constants, as follows:
System.out.println(Size.SMALL.toText()); // toString is defined for all constants
The preceding code will have the following output:
36 X 19
You can also access the behavior that a specific enum constant overrides as follows:
System.out.println(Size.LARGE.toText());
The preceding code will have the following output:
LARGE
However, you can't access the state or behavior that is specific to an enum constant, as shown in ...
Read now
Unlock full access