Previous | Home | Next |
Initialization is the way to initialize the variable .It can be done 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. throwing away the old value of a variable and replacing it with a new one.
To understand assignment and initialization it is must to understand declaration. Declaration is nothing just a way to declare value to a 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.
forexample:
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 |