Monday, 1 September 2014

Increment Operator In Java

Structure of the Problem Requirements 

In this problem we will learn the functionality of increment operator with Java program. 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 . Here is the source code of this problem which help you in better understanding .

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
Increment Operator in Java Program

Share it Please

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.


Post a Comment