permaculture playing cards*
The moose likes Beginning Java and the fly likes pre ++ or pre -- Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "pre ++ or pre --" Watch "pre ++ or pre --" New topic

pre ++ or pre --

patrick van merchtn

Joined: Apr 04, 2007
Posts: 9
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

Joined: Feb 28, 2007
Posts: 1707
You can post questions, codes regarding where you miss, how the things are going on!


patrick van merchtn

Joined: Apr 04, 2007
Posts: 9
no problem, I find it myself. I think it was clear enough.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38031
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.
I agree. Here's the link:
subject: pre ++ or pre --
Similar Threads
increment and decrement operators
Regarding the previous message
Why do i get this run time eroor... plz help
Can anyone explain this program briefly
Basic java