Skip to content

Instantly share code, notes, and snippets.

@MrRahulR
Created May 29, 2021 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrRahulR/81a5dcef3978c554a3f984d1fda26f50 to your computer and use it in GitHub Desktop.
Save MrRahulR/81a5dcef3978c554a3f984d1fda26f50 to your computer and use it in GitHub Desktop.
IncrementDecrementOperator.java
import java.util.Scanner;
public class IncrementDecrementOperator {
public static void main(String[] args) {
int a;
//Scanner class object which is used to take input from the user.
Scanner scanner = new Scanner(System.in);
//Take value of "a" from the user.
System.out.print("Enter value of a : ");
a = scanner.nextInt();
System.out.println("Value of a : " + a);
System.out.println("Increment after performing ++a is " + ++a);
System.out.println("Increment after performing a++ is " + a++);
System.out.println("Decrement after performing --a is " + --a);
System.out.println("Decrement after performing a-- is " + a--);
}
}
/*
Output :
Enter value of a : 10
Value of a : 10
Increment after performing ++a is 11
Increment after performing a++ is 11
Decrement after performing --a is 11
Decrement after performing a-- is 11
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment