India's Largest Free Online Education Platform

Increment operator in java

Increment operator in java


import java.util.Scanner;
public class Increment_Operator
    public static void main(String args[])
        System.out.println("Enter a number");
        Scanner Sc= new Scanner(;
        int x= Sc.nextInt();
        System.out.println("You entered: "+x);
        // Now pre and post increment-
        System.out.println("Post-incremneted value is: "+ x++);
        System.out.println("Pre-incremneted value is: "+ ++x);


Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!