Java Reference
In-Depth Information
//block three
{
int
x = 12;
//...
}
//end block three
//...
}
}
Table 7-3 summarizes the scope (visibility) of the identifiers in Example 7-11.
TABLE 7-3
Scope (Visibility) of the Identifiers
Visibility
in block
three
Visibility
in
two
Visibility
in
main
Visibility
in
one
Identifier
rate
(before
main
)
Y
Y
Y
Y
z
(before
main
)
Y
N
N
N
t
(before
main
)
Y
Y
Y
Y
main
Y
Y
Y
Y
local variables of
main
N
N
N
Y
one
(method name)
Y
Y
Y
Y
x
(
one
's formal parameter)
Y
N
N
N
y
(
one
's formal parameter)
Y
N
N
N
w
(before method
two
)
Y
Y
Y
Y
two
(method name)
Y
Y
Y
Y
one
(
two
's formal parameter)
N
Y
Y
N
z
(
two
's formal parameter)
N
Y
Y
N
local variables of
two
N
Y
Y
N
x
(Block
three
's local
variable)
N
N
Y
N
The Additional Student Files folder at www.cengagebrain.com contains the programs
ScopeRuleA.java
and
ScopeRuleB.java
, and further demonstrates the scope of variables.
Before we look at some programming examples, we will explore the concept of method
overloading.
Search WWH ::
Custom Search