Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

post increment operator question

 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look at the the following code:

The answer is 1 2 1. The first part is clear i.e., i value is printed before incrementing and then incremented value is stored in i and this value is printed in second print statement. The second part is not clear for me. I thought j value would be 2 as the print statement given after incrementing. Can someone explain how does the value of j becomes 1?
 
Cathy Song
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This thread should be helpful..
http://www.coderanch.com/t/243292/java-programmer-SCJP/certification/Infinite-loop-WHY
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic