• iconJava Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Java Variable


Variable:
Variable is an identifier whose value can be changed. or which store the data
Example:
int x=10;
x=20;
Varaible declaration rules:
1.Variable name must be starts with alphabet or underscore or doller symbol.
Example:
int age=10;
int _age=20;
int $age=30;

2.The max length of the variable name is upto 32 characters.
3.If variable name contains morethan one word ,the second word onwords first letter should be
uppercase letter.
Example:
int studentAge=10;
int studentAgeDetails=10;
4.No spaces are allowed at the middle of the variable declaration.
Example:
int student Age=10; (Invalid);
5.If variable value contains constant value that variable name must be
uppercase letter.
Example:
final float PI=3.14;
6.If constant variable name constains morethan one word ,it should be separated with underscore.
Example:
final float PI_VALUE=3.14;
7.All keywords are lower case letters.
Example:
int
float
char
8.We should not take keyword as a variable name.
Example:
int if=10;(Invalid)
int If=10;(Valid)

Variable Defination types:
1.Initilization
2.Declaration
3.Assignment

Initilization:
It Means initilize the some value to the variable.
Example:
int x=10;
Here 10 is initilize to the x.

Declaration:
In the declaration no value initilize to the variable.
Example:
int x;

Assignment:
In the assignment assign the value to the variable or assign variable to the variable.
Example:
int x;
x=10;(It is a value to variable).

int y;
y=x;(It is a variable to variable).