Java Operator Precedence

 

 

                                    Precedence                             Operator                     Operation

 

                                                1                                                              ++                                           Increment

                                                                                                                --                                             Decrement

                                                                                                                +                                              plus (unary)

                                                                                                                -                                               minus (unary)

                                                                                                                !                                               logical NOT

                                                                                                                ~                                              bitwise NOT

 

                                                2                                                              *                                              multiply

                                                                                                                /                                               divide

                                                                                                                %                                            modulus

 

                                                3                                                              +                                              String concatenate

                                                                                                                +                                              arithmatic add (binary)

                                                                                                                -                                               arithmatic subtract (binary)

 

                                                4                                                              <<                                           bitwise left shift

                                                                                                                >>                                           signed right shift

                                                                                                                >>>                                         zero-fill right shift

 

                                                5                                                              <                                              less than

                                                                                                                <=                                           less than or equal to

                                                                                                                >                                              greater than

                                                                                                                >=                                           greater than or equal to

                                                                                                                instanceof                             type comparison

 

                                                6                                                              ==                                           is equal to

                                                                                                                !=                                            is not equal to

                                                                                                                ==                                           refers to same object

                                                                                                                !=                                            refers to different object

 

                                                7                                                              &                                             bitwise AND

                                                                                                                &                                             logical AND

 

                                                8                                                              ^                                              bitwise XOR

                                                                                                                ^                                              logical XOR

 

                                                9                                                              |                                               bitwise OR

                                                                                                                |                                               logical OR

 

                                                10                                                           &&                                         conditional AND

 

                                                11                                                           ||                                               conditional OR

 

                                                12                                                           ? :                                            conditional if - else

 

                                                13                                                           =                                              assignment

                                                                                                                op =                                        assignment with operation