Variable declaration

Variable declarations are considered in the section Variables. There are two syntax forms:

<type> <variable name> ;

<type> <variable name>  = <initial value>;

Examples:

double x;

Person customer = null;

ArrayList<Person> colleagues = new ArrayList<Person>();

Please keep in mind that:

The Figure below illustrates the code areas where local variables exist and can be used.

 

Code areas where local variables exist and can be used