Popular Google Pages:
◕ Bengali Story writing competition. More..
This article is regarding What is the difference between the Initialization and the Assignment Statement in Java?
Last updated on: 15th February 2017.
◕ What is the difference between the Initialization and the Assignment in Java?
■ Initialization causes a variable to have the value that you specify when it is created.
int flower = 786;
This is the Initialization of the variable flower.
Why Initialization is important in Java?
■ On the other hand an assignment involves copying data from one place to another in memory.
In normal practice, we have to declare and initialize variables before using them in the assignment statement.
a = b + c ;
Here the values of the variables b & c are added and final result is stored in the variable a.
The equal sign ' = ' is called the Assignment Operator.
a = b = c = 123;
What is the above statement? An Initialization or an Assignment statement?
Ans:- This is an assignment statement.
Because the compiler allocates some memory to store the constant 123 as type int in the variable c.
The value in c is extracted and copied to b. Then again the value in b is copied to a.
Related Java articles:
■ What is Java? Where we can apply Java?
■ Why Java is a Machine Independent Program? What is Machine Independent Program?
■ Root Directory of Java
■ How to Compile and run a Java Program?
■ What is .class file in Java?
■ What is variable in a program?
■ What is identifier in Java?
■ Integer data types in Java?
■ What is Primitive Types in Java?
■ How to declare constant variables in Java?
■ Why should we declare the initial value of a variable in Java?
■ Use of Underscores to write an integer in Java
Top of the page