Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe for all free courses

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 :



 
© 2021 Learn Java by Examples Template by Hubberspot