created 12/30/98; revised 09/26/99, 01/21/00, 07/14/02
The state of an object is the data it is currently holding.
An object stores its state in its instance variables.
For example, the state of a CheckingAccount
object is the value of the three variables
accountNumber
, accountHolder
,
and balance
.
An object has a state as long as it exists—its
instance variables hold their value until they are explicitly
changed or until the object is destroyed.
An object's methods frequently work with values that are not part of an object's state. These values are held in the local variables and parameters of methods. This chapter discusses how these are declared and used.