Write a program to show the use of auto-increment and auto-decrement operators.
2 years ago
OOP Java
Compile code:
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:

Dipti KC
Jan 8, 2023