Variable Declarations

6.2 Variable Declarations


datatype name;


datatype name=val;


datatype name_1, name_2, ... ,name_n;


You can declare variables anywhere in a method where a statement is valid. The variable's scope will be from the point of declaration to the end of the control structure that contains the variable. Commonly, variables are declared at the beginning of methods (and have scope for the duration of the method) or in the initialization of a loop (and have scope during the loop).

You can also declare variables in a class. These variables have scope in all the class methods and exist as long as a class exists. See the class declaration page for more information on how to do this.
Next 6.3 Strings

David Maxwell, who is still writing this, would like to hear your comments and suggestions.