Increment and Decrement operators
public class Incdec {
public static void main(String[] args) {
int a1 = 5;
--a1; //predecrement
int a2 = 10;
++a2; //preincrement
int b1 = 15;
b1--; //postdecrement
int b2 = 20;
b2++; //postincrement
System.out.println(a1);
System.out.println(a2);
System.out.println(b1);
System.out.println(b2);
}
}
OUTPUT
4
11
14
21
Facebook Comments