Java Increment/Decrement Operators
Resulting data type after arithmetic operation
Increment and Decrement operators
a++, ++a (Increment Operators)
a--, --a (Decrement Operators)
These will operate on all data types except Booleans.
Examples
byte x = 5;
int y = 6;
short z = 8;
int a = y + z;
float b = 6.54f + x;
System.out.println(b);
Output
20.54
int i = 56;
int b = i++; // first b is assigned i (56) then i is incremented
int j = 67;
int c = ++j; // first j is incremented then c is assigned j (68)
System.out.println(i++);
System.out.println(i);
System.out.println(++i);
System.out.println(i);
int y = 7;
System.out.println( ++y *8);
char ch = 'a';
System.out.println(++ch);
Output
57
58
59
59
64
b
58
59
59
64
b