The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes the ++ operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "the ++ operator" Watch "the ++ operator" New topic

the ++ operator

Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331

Considering the code,

I don't understand why the O/P of the code is 0 and not 1... I thought
lineA would reduce to i=0 and just after that assignment is done i value would be incremented, so that println() would see a println(1) but it doesnt seem to be so...

Can you please help me understand this?

marc weber

Joined: Aug 31, 2004
Posts: 11343

See JavaRanch FAQ: Post Increment Operator And Assignment.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: the ++ operator
It's not a secret anymore!