6.3
Scope of a Simple Name
NAMES
The scope of a parameter of a constructor ( 8.6.1) is the entire body of the
constructor.
The scope of a local variable declaration in a block ( 14.3.2) is the rest of the
block in which the declaration appears, starting with its own initializer ( 14.3)
and including any further declarators to the right in the local variable declara
tion statement.
The scope of a local variable declared in the
ForInit
part of a
for
statement
( 14.12) includes all of the following:
N
Its own initializer
N
Any further declarators to the right in the
ForInit
part of the
for
statement
N
The
Expression
and
ForUpdate
parts of the
for
statement
N
The contained
Statement
The scope of a parameter of an exception handler that is declared in a
catch
clause of a
try
statement ( 14.18) is the entire block associated with the
catch
.
These rules imply that declarations of class and interface types need not appear
before uses of the types.
In the example:
package points;
class Point {
int x, y;
PointList list;
Point next;
}
class PointList {
Point first;
}
the use of
PointList
in class
Point
is correct, because the scope of the class type
name
PointList
includes both class
Point
and class
PointList
, as well as any
other type declarations in other compilation units of package
points
.
82
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