Line 7 initializes the variable c
to 5
, and line 8 outputs c
’s initial value. Line 9 outputs the value of the expression c++
. This expression postincrements the variable c
, so c
’s original value (5) is output, then c
’s value is incremented (to 6). Thus, line 9 outputs c
’s initial value (5) again. Line 10 outputs c
’s new value (6) to prove that the variable’s value was indeed incremented in line 9.
Line 15 resets c
’s value to 5
, and line 16 outputs c
’s value. Line 17 outputs the value of the expression ++c
. This expression preincrements c
, so its value is incremented; ...
Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.