Saturday, October 24, 2009

Section 2.6. Operators







2.6. Operators

Operators perform operations on one, two, or three operands and return a result. Operator types in Java include assignment, arithmetic, comparison, bitwise, increment/decrement, and class/object. Table 2-4 contains the Java operators listed in precedence order (those with the highest precedence at the top of the table), along with a brief description of the operators and their associativity (left to right or right to left).

Table 2-4. Java operators
PrecedenceOperatorDescriptionAssociation
1++,--Postincrement, PostdecrementR L
2++,--Preincrement, PredecrementR L
 +,-Unary plus, unary minusR L
 ~Bitwise complimentR L
 !Boolean NOTR L
3newCreate objectR L
 (type)Type castR L
4*,/,%Multiplication, division, remainderL R
5+,-Addition, subtractionL R
 +String concatenationL R
6<<, >>, >>>Left shift, right shift, unsigned right shiftL R
7<, <=, >, >=Less than, less than or equal to, greater than, greater than or equal toL R
 instanceofType comparisonL R
8==, !=Value equality and inequalityL R
 ==, !=Reference equality and inequalityL R
9&Boolean ANDL R
 &Bitwise ANDL R
10^Boolean XORL R
 ^Bitwise XORL R
11|Boolean ORL R
 |Bitwise ORL R
12&&Conditional ANDL R
13||Conditional ORL R
14?:Conditional Ternary OperatorL R
15=,+=,-=, *=,/ =,%=,&=,^=, |=, <<=, >> =, >>>=Assignment OperatorsR L









No comments:

Post a Comment