File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 1710
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: 46349
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 --
It's not a secret anymore!