Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Increment and Decrement
there are in java language we have a two operators that willbe increment and decrement a variable , These operators are composed of either two plus signs (++) or two minus signs (--) : 
> ++ increment (prefix and postfix)
> -- decrement (prefix and postfix)
           The operator is placed either before (prefix) or after (postfix) a variable to change
the value.we can see in this example : 
 class MathTest {
 static int players = 0;
 public static void main (String [] args) {
 System.out.println("players online: " + players++);
 System.out.println("The value of players is " + players);
 System.out.println("The value of players is now " + ++players);
 }
 }
            In this programe program the increment operator is after the variable players. thats a postfix notation that means we are using the postfix increment operator, which causes
the variable players to be incremented by one but only after the value of players is used in the expression.
OUTPUT : 
%java MathTest
players online: 0
The value of players is 1
The value of players is now 2
Posted By: Name:Rajesh Kr URL: Increment and Decrement