Java supports almost all standard operators from the C language. These operators also have the same precedence in Java as they do in C, as shown in the following Table.
| Precedence | Operator | Operand Type | Description |
|---|---|---|---|
| 1 | ++,-- | Arithmetic | Increment and Decrement |
| 1 | +,- | Arithmetic | Unary Plus and unary Minus |
| 1 | ~ | Integral | Bitwise complement |
| 1 | ! | Boolean | Logical Complement |
| 1 | (type) | Any | Cast |
| 2 | *,/,% | Arithmetic | Multiplication, division, remainder |
| 3 | +,- | Arithmetic | Addition and subtraction |
| 3 | + | String | String concatenation |
| 4 | << | Integral | Left Shift |
| 4 | >> | Integral | Right shift with sign extension |
| 4 | >>> | Integral | Right shift with no extension |
| 5 | <,<=,>,>= | Arithmetic | Numeric Comparison |
| 5 | instanceof | Object | Type comparison |
| 6 | ==,!= | Primitive | Equality and inequality of value |
| 6 | ==, != | Object | Equality and inequality of reference |
| 7 | & | Integral | Bitwise AND |
| 7 | & | Boolean | Boolean AND |
| 8 | ^ | Integral | Bitwise XOR |
| 8 | ^ | Boolean | Boolean XOR |
| 9 | | | Integral | Bitwise OR |
| 9 | | | Boolean | Boolean OR |
| 10 | && | Boolean | Conditional AND |
| 11 | || | Boolean | Conditional OR |
| 12 | ?: | N/A | Conditional ternary operator |
| 13 | = | Any | Assignment |






0 comments:
Post a Comment