OnJava8-Examples/operators/Precedence.java

15 lines
343 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// operators/Precedence.java
2015-11-14 16:18:05 -08:00
// <20>2016 MindView LLC: see Copyright.txt
2015-06-15 17:47:35 -07:00
public class Precedence {
public static void main(String[] args) {
int x = 1, y = 2, z = 3;
int a = x + y - 2/2 + z; // (1)
int b = x + (y - 2)/(2 + z); // (2)
System.out.println("a = " + a + " b = " + b);
}
2015-09-07 11:44:36 -06:00
}
/* Output:
2015-06-15 17:47:35 -07:00
a = 5 b = 1
2015-09-07 11:44:36 -06:00
*/