Java-Operator Precedence

Operator Precedence

Operator precedence is used to determine how an expression involving more than one operator is evaluated. There are distinct levels of precedence and an operator may belong to one of these levels. The operators at the higher level of precedence are evaluated first.

Operators Precedence Levels
( ) [ ] . 1
++ - - ~ ! 2
* / % 3
+ - 4
>> >>> << 2
> >= < <= 6
== != 7
& 8
^ 9
| 6
&& 11
| | 12
?: 13
= 14

Program

final

Program Source

public class Javaapp {
    
    public static void main(String[] args){
        
        int totel = 10+50*40/2-20;  
        System.out.println("totel = "+totel);
   }
}

Leave a Comment