Difference Between Prefix Increment and Postfix Increment Operators
Figure 4.15 demonstrates the difference between the prefix increment and postfix increment versions of the ++ increment operator. The decrement operator (--) works similarly.
Click here to view code image
1 // Fig. 4.15: Increment.java 2 // Prefix increment and postfix increment operators. 3
4 public class Increment 5 { 6 public static void main(String[] args) 7 { 8 // demonstrate postfix increment operator 9 int c = 5;10 System.out.printf("c before postincrement: %d%n", c); // prints 511 System.out.printf(" postincrementing c: %d%n", c++); // prints 5
12 System.out.printf(" c after postincrement: %d%n", c); // ...