Variables & Constants

Variables in Java are named memory locations that hold data value of a particular data type. All variables must be declared before they can be used. Initialization is the process of providing value to a variable at declaration time. A variable is initialized once in its life time. To initialize a variable, type the assignment operator on the right side of its name, followed by the value. The names of variables in the Java language are referred to as identifiers. The scope of variables is declared within the block. Java allows variables to be initialized dynamically, using any expression valid at the time the variable is declared. All variables in the Java language must have a data type. A variable's type determines the values that the variable can have and the operations that can be performed on it.

A constant in Java is a variable whose value cannot be changed once it is initially bound to a value. Though a constant value is specified only once, the value can, however, be referenced multiple times within a program. The final keyword is used to declare a variable as constant.

To Access the full content, Please Purchase