Increment and Decrement: Demonstrate ++. : Increment Decrement Operators « Operators « Java Tutorial






public class MainClass {
  public static void main(String args[]) {
    int a = 1;
    int b = 2;
    int c;
    int d;
    c = ++b;
    d = a++;
    c++;
    System.out.println("a = " + a);
    System.out.println("b = " + b);
    System.out.println("c = " + c);
    System.out.println("d = " + d);
  }
}
a = 2
b = 3
c = 4
d = 1








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