Six categories of operators : Operators « Operators « Java Tutorial






In Java, there are six categories of operators.

  1. Unary operators
  2. Arithmetic operators
  3. Relational and conditional operators
  4. Shift and logical operators
  5. Assignment operators
  6. Other operators
Precedence     Operator     Description                          Association
1              ++,--        Postincrement, Postdecrement         R -> L
2              ++,--        Preincrement, Predecrement           R -> L
               +,-          Unary plus, unary minus              R -> L
               ~            Bitwise compliment                   R -> L
               !            Boolean NOT                          R -> L
3              new          Create object                        R -> L
               (type)       Type cast                            R -> L
4              *,/,%        Multiplication, division, remainder  L -> R
5              +,-          Addition, subtraction                L -> R
               +            String concatenation                 L -> R
6              <<, >>, >>>  Left shift, right shift, unsigned right shift     L -> R
7              <, <=, >, >=                                      L -> R
               instanceof   Type comparison                      L -> R
8              ==, !=       Value equality and inequality        L -> R
               ==, !=       Reference equality and inequality    L -> R
9              &            Boolean AND                          L -> R
               &            Bitwise AND                          L -> R
10             ^            Boolean XOR                          L -> R
               ^            Bitwise XOR                          L -> R
11             |            Boolean OR                           L -> R
               |            Bitwise OR                           L -> R
12             &&           Conditional AND                      L -> R
13             ||           Conditional OR                       L -> R
14             ?:           Conditional Ternary Operator         L -> R
15             =,+=,-=,     Assignment Operators                 R -> L
               *=,/ =,%=,
               &=,^=, |=, 
               <<=, >> =, 
               >>>=








3.1.Operators
3.1.1.Six categories of operators
3.1.2.Operator Precedence
3.1.3.The op= Operators
3.1.4.The ternary operator (The Conditional Operator): result = value>conditionValue ? result1 : result2
3.1.5.Tests all the operators on all the primitive data types to show which ones are accepted by the Java compiler