Monday, 23 May 2011

Compound operators in java

The compound operators perform shortcuts in common programming operations. Java has eleven compound assignment operators.
Syntax:

argument1 operator = argument2.

The above statement is the same as, argument1 = argument1 operator argument2. An example program is shown below that demonstrates the different Compound operators in java.

int x = 0, y = 5;
x += 3; //x = 3 now
y *= x; // y = 5*x = 15

No comments:

Post a Comment