The format of the declaration statement is:
Class-name Variable-name ;
It is a statement ending with a semicolon after specifying the class name and variable name.
This statement introduces a variable into a particular scope of the program and binds the specified class to the variable.
You can access the variable by name within the declared scope.
Variables can be declared any number in any location. However, it is not possible to declare a variable with the same name in the same scope.
Variables with the same name can be declared if scope is different. In this case, the variable declared at the inside scope hides the outside variable with same name.
It represents a class that is bound to a variable.
It is an identifier used to access a variable.
The end of a declaration statement is represented by a semicolon.
open method void someMethod()
int x; // ♦1
int x; // ♦2
All are declarations for variables of the int class. These variables can only handle instances of the int class.
♦1 and ♦2 declare variables with the same name in different scope. Each hides the outer variable with the same name.