Program to demonstrate how Auto Increment/Decrement operator works in Java
Output of the program :
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 :
