OnJava8-Examples/operators/Precedence.java
2015-11-15 15:51:35 -08:00

17 lines
480 B
Java

// operators/Precedence.java
// ©2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
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);
}
}
/* Output:
a = 5 b = 1
*/