Java Reference
In-Depth Information
The output generated by this program is shown here:
As you can see, y is always reinitialized to -1 each time the inner for loop is entered. Even
though it is subsequently assigned the value 100, this value is lost.
There is one quirk to Java's scope rules that may surprise you: although blocks can be
nested, no variable declared within an inner scope can have the same name as a variable
declared by an enclosing scope. For example, the following program, which tries to declare
two separate variables with the same name, will not compile.
Search WWH ::




Custom Search