The answer is given below.
The increment operator ++
adds one to a variable.
Usually the variable is an integer type (byte, short, int, or long)
but it can be a floating point type (float or double.)
The two plus signs must not be separated by any character.
Usually they are written immediately adjacent to the variable,
as in the following:
int counter=0; while ( counter < 10 ) { System.out.println("counter is now " + counter ); counter++ ; }
The increment operator can be used as part of an arithmetic expression, as in the following:
int sum = 0; int counter = 10; sum = counter++ ; System.out.println("sum: "+ sum " + counter: " + counter );
It is vital to carefully study the following:
counter
is incremented after
the value it holds has been used.=
counter
has not been incremented yet.)=
++
operator works: counter
is incremented to 11.sum: 10 counter: 11