TYPES, VALUES, AND VARIABLES
Kinds of Variables
4.5.3
4.
Method parameters
( 8.4.1) name argument values passed to a method. For
every parameter declared in a method declaration, a new parameter variable is
created each time that method is invoked ( 15.11). The new variable is initial
ized 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.6.1) name argument values passed to a construc
tor. For every parameter declared in a constructor declaration, a new parame
ter variable is created each time a class instance creation expression ( 15.8) or
explicit constructor invocation ( 8.6.5) invokes that constructor. The new
variable is initialized with the corresponding argument value from the cre
ation expression or constructor invocation. The constructor parameter effec
tively ceases to exist when the execution of the body of the constructor is
complete.
6. An
exception handler parameter
is created each time an exception is caught
by a
catch
clause of a
try
statement ( 14.18). The new variable is initialized
with the actual object associated with the exception ( 11.3, 14.16). The
exception handler parameter effectively ceases to exist when execution of the
block associated with the
catch
clause is complete.
7.
Local variables
are declared by local variable declaration statements ( 14.3).
Whenever the flow of control enters a block ( 14.2) or
for
statement
( 14.12), a new variable is created for each local variable declared in a local
variable declaration statement immediately contained within that block or
for
statement. A local variable declaration statement may contain an expression
which initializes the variable. The local variable with an initializing expres
sion is not initialized, however, until the local variable declaration statement
that declares it is executed. (The rules of definite assignment ( 16) prevent the
value of a local variable from being used before it has been initialized or oth
erwise assigned a value.) The local variable effectively ceases to exist when
the execution of the block or
for
statement is complete.
Were it not for one exceptional situation, a local variable could always be
regarded as being created when its local variable declaration statement is exe
cuted. The exceptional situation involves the
switch
statement ( 14.9), where
it is possible for control to enter a block but bypass execution of a local vari
able declaration statement. Because of the restrictions imposed by the rules of
definite assignment ( 16), however, the local variable declared by such a
bypassed local variable declaration statement cannot be used before it has
been definitely assigned a value by an assignment expression ( 15.25).
45
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved