Pre increment vs Post increment in array

You hit the nail on the head. Your understanding is correct. The difference between pre and post increment expressions is just like it sounds. Pre-incrementation means the variable is incremented before the expression is set or evaluated. Post-incrementation means the expression is set or evaluated, and then the variable is altered. It’s easy to think … Read more

Incrementor logic

Quoting Java Language Specification, 15.7 Evaluation Order: The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right. The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated. If the operator … Read more

post increment operator java

Let’s break down your own argument: According to the author, j=j++; is similar to temp=j; j=j+1; // increment j=temp; // then assign Yes, you’re right so far…, but here’s where you got it wrong: But a=b++; makes b=1. So it should’ve evaluated like this, a=b; // assign b=b+1; // then increment WRONG! You’re not applying … Read more