Friday 15 September 2017

Java Increment Expression in a 'for' Loop

Cited from the Book Java How to Program

The increment expression in a for acts as if it were a standalone statement after  its body executes. Therefore, the expressions

counter = counter +1
counter += 1
counter ++
++ counter

are equivalent increment expressions in a for statement.

No comments:

Post a Comment