OnJava8-Examples/operators/Precedence.java

13 lines
307 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: operators/Precedence.java
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
*///:~