The prefix form and the postfix form : Increment Decrement Operators « Operators « Java Tutorial






public class MainClass {
  public static void main(String[] args) {
    int numA = 5;
    int numB = 10;
    int numC = 0;

    numC = ++numA + numB;

    System.out.println(numA);
    System.out.println(numC);
  }
}
6
16
public class MainClass {
  public static void main(String[] args) {
    int numA = 5;
    int numB = 10;
    int numC = 0;

    numC = --numA + numB--;
    System.out.println(numA);
    System.out.println(numC);
  }
}
4
14








3.3.Increment Decrement Operators
3.3.1.Increment and Decrement: Demonstrate ++.
3.3.2.The increment and decrement operators
3.3.3.Using the increment and decrement operators in an expression
3.3.4.The prefix form and the postfix form
3.3.5.Using ++ and -- with floating-point variables