Possible Duplicate:
Is there a difference between x++ and ++x in java?
Can anyone please explain me what is happening backyard to these statements?
int x=5;
System.out.println((x++)*x); //Gives output as 30
int x=5;
System.out.println((++x)*x); //Gives output as 36.
You first take x (x = 5) as an operand. Then it’s incremented to 6 which is second operand.
You first increment x by one (x = 6) and then multiply by x => 6 * 6 = 36