Java Reference
In-Depth Information
It returns
true
if the invoking thread is still running, and
false
if it has been termin-
ated.
Chapter 12: Enumerations, Autoboxing, Static Import, and An-
notations
In the term
self-typed
, the “self” refers to the type of the enumeration in which the
constant is defined. Thus, an enumeration constant is an object of the enumeration of
which it is a part.
The
Enum
class is automatically inherited by all enumerations.
the constants and their ordinal values.
The solution is
4
.
The traffic light simulation developed in
Try This 12-1
can be improved with a few
simple changes that take advantage of an enumeration's class features. In the version
shown, the duration of each color was controlled by the
TrafficLightSimulator
class
by hard-coding these values into the
run( )
method. Change this so that the duration
of each color is stored by the constants in the
TrafficLightColor
enumeration. To do