balance
hold its value permanently?
balance
is part of the state of the object and holds its
value as long as the object exists. amount
hold its value permanently?
amount
is used only to pass in a value into the method.
It does not permanently hold a value.An identifier is a name used for a class, a variable, a method, or a parameter. The following definitions are useful:
amount
is a
formal parameter of processDeposit
200
used when processDeposit
is called is an actual parameter.When a method is called, the formal parameter is temporarily "bound" to the actual parameter. The method uses the formal parameter to stand for the actual value that the caller wants the method to use.
For example, the processDeposit
method
uses the formal parameter amount
to stand for the actual value
used in the procedure call:
balance = balance + amount ;
Formal parameters are bound to an actual value only as long as their method is active. When a method returns to its caller, the formal parameters no longer contain any values. They cannot be used to store the state of an object.
The next time a formal parameter is used, it starts with a fresh value. It does remember the previous value it had.
What is used to store the state of an object?