Pin It

How Operator Precedence works in Java ?

Program to demonstrate how Operator Precedence works in Java

public class PrecedenceTest {
 
  public static void main(String[] args) {
  
    int a = 1, b = 2, c = 3;
  
    int x = a + b - 2/2 + c;
  
    int y = a + (b - 2)/(2 + c);
  
    int z = (a + b) - 2/(2 + c);
  
    System.out.println("x = " + x);
    System.out.println("y = " + y);
    System.out.println("z = " + z);

  }

}


Output of the program :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot