A variable is a data name that is used to store the data value. Constant variable cannot be changed during the execution of a program.
A variable is a symbol or name that stands for a value. It is a value that can change. A variable can take different values during the execution. It can be choose by the programmer in many ways.
c = a + b
This is an example of programming expression.
a, b and c are variables.
In every program, variable has its own:
Variable consists of letters, digits and the underscore (_) character. It has following conditions:
1 Uppercase and lower case is significant.
For example: The variable Average is not the same as average or AVERAGE
2 They must begin with a letter.
3 It should not be a keyword.
4 White space is not allowed.
SUM1 ph_value Mumbai
John Value distance
Example of variable names
Dollar sign is not valid
Blank space is not allowed
Keyword may be the part of a name
Variables can represent numeric values, characters, character strings, or memory addresses.
Local Variables Instance Variables Static Variables
·Local variable- A variable that is declared inside the method that is called local variable.
·Instance variable- A variable that declared the inside the class but outside the method that is called instance variable.
·Static variable-A static Variable is a special type of the variable that is shared by all objects from a class. Static variable are used to keep track of global information such as number of objects from a class
public static void main(String args)
int data=50; //instance variable
static int m=100; //static variable
int n=90;//local variable
}//end of class