Operators in java programming language

This entry is part 13 of 34 in the series Core Java Course

In this section we will learn about Operator Precedence and Operator Associativity.

Operator Precedence

Precedence decides which operator will be evaluated first in a case where more than one operator is present in the same calculation.

Operator Precedence Table

Operators Precedence(High to Low)
postfix expr++ expr--
unary ++expr --expr +expr -expr ~ !
multiplicative * / %
additive + -
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
ternary ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=

Example of Precedence

Operator Associativity

If two operators have the same precedence in the calculation then Associativity of the operators will be used to decide which operator will be executed first.

Example of Associativity


Operators in Java

Let us discuss each operator individually.

Assignment (=) and  Arithmetic operators(+, -, *, /) work the same way as they do in other programming languages, so we will not discuss them here. The precedence for  ‘/‘  and  ‘*‘ operators is higher than sum(+) or minus() or modular division(%)

Series Navigation<< Non Access Modifiers in JavaJava Statements tutorial for Beginners >>

51 Comments Operators in java programming language

  1. Raj

    Accidentally came to this site. but not able to leave the site:) nicely written, nice to read. Thanks!!!

          1. Mayank Srivastava

            Bhai.. good work. Will finish up quickly everything , from start to end.
            Everything is compiled so nicely , that’s required for each developer to know.

  2. randki

    Do you mind if I quote a few of your posts as long as I provide credit and sources back to
    your webpage? My blog is in the exact same niche as yours and
    my visitors would truly benefit from some of the information you provide
    here. Please let me know if this okay with you. Thank you!

  3. vidya

    learning java became soo easy.. !!! i love this website..!!! this helps beginners alot.. !! expecting more from you… :)

  4. adithyan

    HI gautam, i have a doubt that what are the things which will come outside the main and what are the things will come inside the main method, there is a huge confusion about this and where the program actually starts??? plz kindly help me……………….. waiting for the reply

  5. Param Gates

    I wanted to learn Java. I googled and reached your site. Your syllabus is very easy to understand and can be self learned. Thanks for the site and wishes for your hardwork.

  6. Akshay

    Really Nice Website for Beginners……….(Y)
    Every concept explained in detaill and easy to understand way………….

  7. Aaisha

    Could you please explain to me the following expression

    int m=i/(k*2)+j;
    (precedence doesn’t come into action and that is understood)
    While evaluating the expression this is what happens(40/(40*2)+80)=(40/(80)+80)==(1+80)==81
    Always the (/) is considered to give us the quotient.

    Please do explain the same.

  8. Parthiban P

    Really very useful for beginners…

    Just let me know some other same tuorials for SQL and Javascirpt….

    Appreciate your concern on this..:-)

  9. aditya vardhan

    This site is incredible!!!!!!!…. This is what a beginner is looking for… Sooo easy and worthy…. Kudos Author

  10. arpitha

    In my side opinion is examples will be given on understanding purpose but that examples will be not understandable way.try to get user understandable examples.

  11. rams

    Today I stated the learning by seeing this blog, I am the new one to programming. Your blessing is required

  12. Jyothy

    Very good site. It includes good details about Core Java. I am learning Core Java at the moment. i would like to complete Core Java and also rest of the sections.

    Thanks for good compilation with good examples.


Leave A Comment

Your email address will not be published. Required fields are marked *