What is variable ?
It is Container used to store the value with a unique name.
Java is statically typed , so every variable must be declared a specific data type before it can be used. Syntax
String name = "Ajay"; int age = 20;
Enter fullscreen mode
Exit fullscreen mode
here,
Right side of assignment operator (=) is value,
left side of assignment operator (=) is variable,
Here the Value(Ajay) is stored in the variable (name),
In memory the value is only converted into bit and stored, not an variable, varaible is an identication of the value were we stored in the memory.
Rule of creating a variable?
Variable are Case Sensitive (age and Age are differect).
Variable name should not start with digits,It must begin with a valid identifier-start character, such as a letter, _, or $.
No reserved keyword are used as variable name.
Variable name cannot contain space.
Variable name should be meaningful name.
Type of variables
Local variables
Local varibales are created only inside the methods ,…