Table 65 lists the operators in the Java programming language. Operators higher in the table have higher precedence than do those lower in the table. Operators on the same line have the same precedence.
Operator Category |
Operators |
---|---|
Postfix operators |
[] . (params) expr++ expr-- |
Unary operators |
++expr --expr +expr -expr ~ ! |
Creation or cast |
new (type)expr |
Multiplicative |
* / % |
Additive |
+ - |
Shift |
<< >> >>> |
Relational |
< > <= >= instanceof |
Equality |
== != |
Bitwise AND |
& |
Bitwise exclusive OR |
^ |
Bitwise inclusive OR |
| |
Logical AND |
&& |
Logical OR |
|| |
Conditional |
?: |
Assignment |
= += -= *= /= %= ^= &= |= <<= >>= >>>= |
When operators of equal precedence appear in the same expression, a rule must govern which is evaluated first. In the Java programming language, all binary operators except for the assignment operators are evaluated in left-to-right order. Assignment operators are evaluated in right-to-left order.
Getting Started
Object-Oriented Programming Concepts
Language Basics
Object Basics and Simple Data Objects
Classes and Inheritance
Interfaces and Packages
Handling Errors Using Exceptions
Threads: Doing Two or More Tasks at Once
I/O: Reading and Writing
User Interfaces That Swing
Appendix A. Common Problems and Their Solutions
Appendix B. Internet-Ready Applets
Appendix C. Collections
Appendix D. Deprecated Thread Methods
Appendix E. Reference