++x (pre-increment) means "increment the variable; the value of the expression is the final value"
x++ (post-increment) means "remember the original value, then increment the variable; the value of the expression is the original value"
int x =0;
// POST increments: increments after it prints x or stmt
System.out.println("Hello World"+ x++); // 0
System.out.println("Hello World"+ x); // 1
// PRE increments: increments before it prints x or stmt
System.out.println("Hello World"+ ++x); // 1
System.out.println("Hello World"+ x); // 1
Pre-increment (++i) − Before assigning the value to the variable, the value is
incremented by one.
Post-increment (i++) − After assigning the value to the variable, the value is
incremented.
++x (pre-increment) means "increment the variable; the value of the expression is the final value"
x++ (post-increment) means "remember the original value, then increment the variable; the value of the expression is the original value"
int x =0;
// POST increments: increments after it prints x or stmt
System.out.println("Hello World"+ x++); // 0
System.out.println("Hello World"+ x); // 1
// PRE increments: increments before it prints x or stmt
System.out.println("Hello World"+ ++x); // 1
System.out.println("Hello World"+ x); // 1
Pre-increment (++i) − Before assigning the value to the variable, the value is
incremented by one.
Post-increment (i++) − After assigning the value to the variable, the value is
incremented.