The operators for incrementing and decrementing in Java has been irritating me for some time now, just when I think I understand whats going on, I try a mock exam for SCJP and I get caught out. So I’ve decided to sit down, do a bit of reading, and drill it out.

Take this example, what do you think the output will be?

int a = 1;
int b = 5;
System.out.print("a++ is : " + a++);
System.out.print("++b is : " + ++b);

The output will be :

1
6

Share