Increment Operator In Java

The sign which use for increment Operator is ++. There are two types of Increment operator, one is Prefix Increment operator and the second is Postfix Increment operator. The Prefix Increment operator (++a) and the Postfix increment operator is (a++). The Prefix increment follow the rule " change then use " while Postfix follow the rule " Use then change ". In Prefix condition first the variable value change and then used and in Postfix condition the variable value used first and then change .

Source Code


import java.util.Scanner;
public class Increment_operator{
public static void main(String[] args) {
int a = 1;
int b = 1;
a = ++a;
b = b++;
System.out.println(" This is Prefix Increment Operator : " + a);
System.out.println(" This is Prefix Increment Operator : " + b);
}
 }

Output of the Program

Increment Operator

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment