Write a Java program to print Pre Increment operation?

Write a Java program to print Pre Increment operation


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

Output:

The PreIncrement value is 11




Using commandLine arguments

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

Output:

The PreIncrement value is 11




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 PreIncrement value is "+(++x));
}
}
                                            

Output:

Enter x value 10
The PreIncrement value is 11







More Programs


2 . PreIncrement Program
3 . PostIncrement Program
4 . PreDecrement Program
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