Java Reference
In-Depth Information
when the comet object is created and so the field cannot be
final
. Fin-
ally, if initialization of the field is expensive and the field's value is infre-
quently needed, then it may be more practical to defer the initialization
of the field until its value is neededthis is generally termed
lazy initializ-
ation
which cannot be done to a
final
field.
There are additional considerations concerning
final
fields if your object
must be clonable or serializable. These are discussed in "
Cloning Ob-
Exercise 2.4
: Consider your solution to Exercise 2.3. Do you think the
identification number field should be
final
?