
Type casting is discussed in
Chapter 2.
REFERENCE POINT
7.10 The toString and equals Methods 407
with comparing o’s fields and this Auto object’s fields. Before performing
the comparison, we must cast the Object reference o to an Auto (line 116).
Otherwise, there would be a compiler error when trying to access the
instance variable model with the Object o, because model is an instance vari-
able of class Auto and not of class Object.
We compare each instance variable in the parameter object, objAuto, with
the same instance variable in this object. We return true if the correspon-
ding instance variables in each object have the same values; otherwise, ...