Assignments and Initializations

Assignments and Initializations

Previous Home Next

 

Initialization is the way to initialize the variable .it occurs at the time of declaration.
Assignments is the way to assign the value to the variable it can be done anywhere only once with the final identifier.


To understand assignment and initialization it is must to understand declaration.
Declaration is nothing just a way of declaring variable.
java variables assign or given values using one of the assignment

we cannot assign a value to a constant but we can initialize it .this is the big difference  between the initialization and assignment. can be done many times while initialization occur only once.

 
int a; //declaration
a=5; //initialization, assignment operators are used to assign value to the variable

float a,b, sum;
a=5;
b=4;
sum=a+b;//a+b is assigning to sum.




 
int a;  //declaration
a=5; //initialization


float a,b,sum

a=5;
b=4;
sum=a+b; // a+b is assign to the variable sum.

Previous Home Next