This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Yes and if you have them as a command by themselves, they work the same. If you have them in a command that also does something else, you get different results because they increment/decrement at different times.
Try running the following code:
They give different results because they increment at different times.
so i++ returns the value and then increments and ++i increments the value then returns
Both actually increment the value of i *first*, and then return. The difference is that i++ returns the value i had before the increment, ++i returns the value i has after the increment.
That is why
i = i++;
doesn't change the value of i at all. Or more precisely, it first increments the value of i, and then sets it back to the old value.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus