SOURCE http://www.imooc.com/code/1315
The so-called priority is the order of operations in an expression. The precedence of operators commonly used in Java is shown in the following table:
Level 1 has the highest priority, and level 11 has the lowest priority . For example, the result of x = 7 + 3 * 2 is 13 "Multiply First and add"!
PS: We don't have to go. The order of precedence of the rote operators, which is typically used to assist in priority management in real-world development. For example:
Analysis: Parentheses have the highest precedence, so
1, execute a + 18, the result is 30
2, perform (A + 18)% 4 modulo, the result is 2
3, execute A * ((A + 18)% 4), the result is 24
Task
In the editor, enter the line 5 :
int x = (M * 8/(n + 2))% m;
Combined with the results of the operation: I believe you will have a clearer understanding of operator precedence!
1 Public classHelloWorld {2 Public Static voidMain (string[] args) {3 intm = 5;4 intn = 7;5 intx = (M * 8/(n + 2))%m;6System.out.println ("M:" +m);7System.out.println ("N:" +n);8System.out.println ("x:" +x);9 }Ten}
Mu Net-android engineer first form the precedence of operators in -3-9 Java