Write a Java program to print post Decrement operation?

Write a Java program to print post Decrement operation


class Main
{
    public static void main(String args[])
    {
        int x=10;
        System.out.println("The PostDecrement value is "+(x--));
    }
}	
                                            

Output:

The PostDecrement value is 10




Using commandLine arguments

class Main
{
    public static void main(String args[])
    {
        int x;
        x=Integer.parseInt(args[0]);
        System.out.println("The PostDecrement value is "+(x--));
    }
}
                                            

Output:

The PostDecrement value is 10




Using Scanner class

import java.util.*;
class Main
{
    public static void main(String args[])
    {
        int x;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter x value ");
        x=s.nextInt();
        System.out.println("The PostDecrement value is "+(x--));
}
}
                                            

Output:

Enter x value 10
The PreDecrement value is 10







More Programs


5 . PostDecrement Program
6 . Addition Program
7 . Substraction Program
8 . Multiplication Program
9 . Division Program
10 . Modular Division Program
11 . Swaping Of Two Numbers With Using Third Variable
12 . Swaping Of Two Numbers Without Using Third Variable
13 . Relation Of Two Numbers Program using > < <= >= !=
14 . Logical Operators Program using &&, || ,!
15 . Bitwise AND Program