Java Reference
In-Depth Information
good programming practice requires that the programmer satisfy herself that despite
any unchecked warning, the code is correct and heap pollution will not occur.
4.12.3. Kinds of Variables
There are seven kinds of variables:
1. A
class variable
is a field declared using the keyword
static
within a class declara-
when its class or interface is unloaded (§
12.7
).
2. An
instance variable
is a field declared within a class declaration without using the
If a class
T
has a field
a
that is an instance variable, then a new instance variable
a
able effectively ceases to exist when the object of which it is a field is no longer
pleted.
3.
Array components
are unnamed variables that are created and initialized to default
The array components effectively cease to exist when the array is no longer refer-
enced.
For every parameter declared in a method declaration, a new parameter variable is
created each time that method is invoked (§
15.12
). The new variable is initialized
with the corresponding argument value from the method invocation. The method
parameter effectively ceases to exist when the execution of the body of the method
is complete.
5.
Constructor parameters
(§
8.8.1
) name argument values passed to a constructor.
For every parameter declared in a constructor declaration, a new parameter vari-
constructor invocation (§
8.8.7
) invokes that constructor. The new variable is ini-
tialized with the corresponding argument value from the creation expression or
constructor invocation. The constructor parameter effectively ceases to exist when
the execution of the body of the constructor is complete.