Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pre ++ or pre --

 
patrick van merchtn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post increment or post decrement is clear, but I am still confused about what the result is and when to use pre increment or pre decrement.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can post questions, codes regarding where you miss, how the things are going on!




Regards,
cmbhatt
 
patrick van merchtn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no problem, I find it myself. I think it was clear enough.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a simple answer about pre-increment and pre-decrement if you are confused about them. Don't use them.
Try this silly little code snippetSee what you get. Now repeat the whole exercise with ++i instead of i++.

Can you work out why you get different results? There is more in the Java Tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic