shortcut operatorsIs it possible to do short hand when using Java Operators? The answer is "Yes" , we show here a good list of frequently used operators in java and we illustrate how it could be short handed :
Shortcut (shorthand) arithmetic operators1- Operator (+=)Example :
java code
x+=y;
same as :
java code
x=x+y;
2- Operator (-=)Example :
java code
x-=y;
same as :
java code
x=x-y;
3. Operator (*=)Example :
java code
x*=y;
same as :
java code
x=x*y;
4. Operator (/=)Example :
java code
x/=y;
same as :
java code
x=x/y;
5. Operator (%=)Example :
java code
x%=y;
same as :
java code
x=x%y;
Shortcut (shorthand) bitwise operators6. Operator (&=) Bitwise Operator ?
Example :
java code
x&=y;
same as :
java code
x=x&y;
7. Operator (|=)
Example :
java code
x|=y;
same as :
java code
x=x|y;
8. Operator (^=)
Example :
java code
x^=y;
same as :
java code
x=x^y;
9.Operator (>>=)
Example :
java code
x>>=y;
same as
java code
result=x>>y;
The same operation to operator (<<=) and operator (>>>=) .