Assignments and Initialization in Java
Posted by
Ravi Kumar at Wednesday, March 4, 2009
Share this post:
|
0 Comments
After declaring a variable, we initialize a value by using assignment statement. We assign to a previously declared variable using the variable name on the left, an equal sign (=), and then some Java expression that has an appropriate value on the right.
Int Days; // this is a declaration
Days = 30; // this is an assignment
Another feature of Java is we can do both declare and initialize a variable on the same line.
Ex: Int Days = 30; // this is an initialization
In Java you can put declarations anywhere in your code.