Java-Operator Associativity

Operator Associativity

The operators of the same precedence are evaluated either from ‘left to right’ or ‘right to left’, depending on the level. This is known as the associativity property of an operator.

Operators Associativity
( ) [ ] . Left to Right
++ - - ~ ! Right to Left
* / % Left to Right
+ - Left to Right
>> >>> << Left to Right
> >= < <= Left to Right
== != Left to Right
& Left to Right
^ Left to Right
| Left to Right
&& Left to Right
| | Left to Right
?: Right to Left
= Right to Left

Program



Program Source

public class Javaapp {
    
    public static void main(String[] args) {
        
        int totel = 10+50-30+60-60;
        System.out.println("Totel = "+totel);
    }
}

Leave a Comment