Header Ads

  • Breaking Now

    What is associativity of operators in Java?

    Associativity is the grouping of operands and operators in an expression where more than one operator of the same precedence exist.

    When the operations in an expression all have the same precedence rating, the associativity rules determine the order of the operations. For most operators, the evaluation is done left to right, e.g.

    x = a + b - c;

    Here, addition and subtraction have the same precedence rating and so a and b are added and then from this sum c is subtracted. Again, parentheses can be used to overrule the default associativity, e.g.

    x = a + (b - c);


    All other operators,except shown in the table below are evaluated left to right(see precedence table).




    Post Top Ad

    Post Bottom Ad