Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

shortcut operators

Fri Jan 30, 2009 12:48 pm

shortcut operators
Is 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 operators
1- 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 operators

6. 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 (>>>=) .



Post a reply
  Related Posts  to : shortcut operators
 PHP operators     -  
 Bitwise operators     -  
 Equality Operators     -  
 C++ Increment Operators     -  
 Using Assignment Operators     -  
 using bit-wise operators in c++     -  
 difference between the >> and >>> operators     -  
 bitwise operators usage in C++     -  
 Use the boolean compare operators     -  
 Comparison Operators in java     -  

Topic Tags

Java Basics