• Register
100 points
4

Overview

In this kodlogs article , we will quickly talk about the increment and decrement unary operators in Java.We'll begin via searching at the syntax observed by means of the usage.

Increment &Decrement in java

 In Java, the increment unary operator will increase the cost of the variable by means of one whilst the decrement unary operator decreases the fee of the variable by using one.Both replace the fee of the operand to its new value.The operand required need to be a variable that is no longer constant, as we would not be capable to regulate its value. Furthermore, the operand cannot be an expression due to the fact we can't replace them.

Two Forms

The increment and decrement unary operators have two forms, which are, prefix and postfix. 

Prefix Form:

The increment and decrement unary operators show up earlier than the operand.

While the use of the prefix form, we first replace the fee of the operand and then we use the new cost in the expression.

Postfix Form:

The operator seems after the operand.While the usage of the postfix form, we first use the price of the operand in the expression and then replace it.

Example Increment 

int a=5;
a++;

O/P
6

Example Decrement 

int b=10;
a- -;
O/P
9

 

100 points
4