A variable's scope is the block of code within which the variable is accessible.
A local variable declared in a block (region delimited by braces) can be used only in that block of in blocks nested within that block.
Methods and instance variables of a class have class scope. Class scope is the region enclosed by the braces following the class declaration.
public class Scope extends JApplet { double x = 15; // instance variable public void MethodA(double y) // Method parameter { double z = 3.14; // local variable } }
Identifiers declared within a block have block scope. Both local variables and method parameters have block scope.
Maintained by John Loomis, last updated 1 June 2000