Pin It

How Auto Increment/Decrement operator works in Java ?

Program to demonstrate how Auto Increment/Decrement operator works in Java

public class IncrementDecrement {
 
   public static void main(String[] args) {
  
      int x = 1;
  
      System.out.println("The value of x: " + x);
      System.out.println("The value of ++x: " + ++x);
      System.out.println("The value of x++: " + x++);
      System.out.println("The value of x now: " + x);
      System.out.println("The value of --x: " + --x);
      System.out.println("The value of x--: " + x--);
      System.out.println("The value of x now: " + x);
  
   }

}

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