A loop control variable is incremented.
Frequently the last statement in the body of a counting loop is something like:
count = count + 1;
This is so common that there is a shorter way to do it:
count++ ;
Both statements add one to the value in the variable. Almost always the operator is used with an integer variable (although it does work with floating point.) Here is a previously seen program rewritten with this operator:
// Example of a while loop
public class LoopExample
{
public static void main (String[] args )
{
// start count out at one
int count = 1;
// loop while count is <= 3
while ( count <= 3 )
{
System.out.println( "count is:" + count );
// add one to count
count++ ; // previously count = count + 1;
}
System.out.println( "Done with the loop" );
}
}
The "postfix" part of the name means that the operator is placed after the variable name.
What do you suspect this does: count-- ;