A variable is a symbolic name for a location in memory used to store data. The value stored in a variable can be modified and read during the execution of the Java program. To use a variable in a Java, it must be first be created. Creating a variable in Java is done by stating the variable type and by giving it an identifier (the variable name).
Three sections are necessary for creating variables in Java:
Example: to create a variable in Java with the variable name {identifier} of "max" :
int max;
You can create many variables of the same type at once, for example:
int max, min;
Rules for variable names:
NOTE: It is important to initialize a variable (set it to some value) before you use it in a calculation or print it. If you do not initialize the variable, Java will cause a compile error.