Monday, March 23, 2009

Assignment Operator In JAVA

The assignment operator in java is the most frequently used operator. This operator is used to assign the value on its right to the variable on the left. The general format for the assignment operator is given below.

variable_name = expression;

where,
expression is an arthmetic expression built using constants, variables and binary operators.
variable_name is the name of the variable to which the expression should be assigned.

For Example

a = 3;
x = 1*3;
num - x+8;
num1 = (4*a)+(21-a)

Note
It is also possible to assgn single value to multiple variables as shown below.

i = j = k = 10;
which will assgn the value 10 to the variables i, j and k.

No comments:

Post a Comment