Computer Science

Explain the meaning of the following short hand operators:

+=

<<=

*=

>>=

%=

/=

!=

Values & Data Types Java

3 Likes

Answer

OperatorsMeaning
+=It is 'Add AND assign' operator. It adds right operand with left operand and assigns the result to the left operand.
Example: a += b; is equivalent to a = a + b;
<<=It is 'Left Shift AND assign' operator. It shifts the binary pattern of the left operand by defined number of bits left and assigns the result to the left operand.
Example: a <<= 2 is equivalent to a = a << 2;
*=It is 'Multiply AND assign' operator. It multiplies right operand with the left operand and assigns the result to the left operand.
Example: a *= b; is equivalent to a = a * b;
>>=It is 'Right Shift AND assign' operator. It shifts the binary pattern of the left operand by defined number of bits right and assigns the result to the left operand.
Example: a >>= 2 is equivalent to a = a >> 2;
%=It is 'Modulus AND assign' operator. It divides the left operand by right operand and assigns remainder to the left operand.
Example: a %= b is equivalent to a = a % b
/=It is 'Divide AND assign' operator. It divides the left operand by right operand and assigns the result to the left operand.
Example: a /= b is equivalent to a = a / b
!=It is 'not equal to' operator. It checks if values of its two operands are unequal or not. If its operands are not equal, it returns true otherwise it returns false.
Example: a != b ⇒ true if a and b are not equal otherwise false.

Answered By

3 Likes


Related Questions