Categories of Variables

An instance field belongs to an object.

The fields stay alive until no method uses the object any longer

Instance fields are initialized to a default value.

 

Both local variables and parameter variables belong to methods 

They come alive when the method is called, and they die when the method exits.

They differ in their initialization.

Parameter variables are initialized with the call values;

local variables must be explicitly initialized.

 

In Java, the garbage collector periodically reclaims objects when they are no longer used

Use BankAccountTester program to see three categories of variables.