English, asked by wazidali, 1 year ago

compound assignment operator

Answers

Answered by Anonymous
0

Java supports 11 compound assignment operators:

+=   assigns the result of the addition. -=   assigns the result of the subtraction. *=   assigns the result of the multiplication /=   assigns the result of the division. %=   assigns the remainder of the division. &=   assigns the result of the logical AND. |=   assigns the result of the logical OR. ^=   assigns the result of the logical XOR. <<=  assigns the result of the signed left bit shift. >>=  assigns the result of the signed right bit shift. >>>= assigns the result of the unsigned right bit shift.

Examples:

To assign the result of an addition operation to a variable using standard syntax:

//add 2 to the value of number number = number + 2;

But use a compound-assignment operator to effect the same outcome with simpler syntax:

//add 2 to the value of number number += 2;
Answered by Akashmilky
1
Compound-assignment operators provide a shorter syntax for assigning the result of an arithmetic or bitwise operator. They perform the operation on the two operands before assigning the result to the first operand
i hope this will help you

wazidali: the compound assignment operator combine the simple assignment operator with another binary operator. compound assignment operator perform the operation specifide by the additional operator,and than assign the result to the left operand
Similar questions