wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ++ operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "++ operator " Watch "++ operator " New topic
Author

++ operator

Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
int i = 0;
i = i++;
i returns 0, why?
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
because you have the ++ after the variable, so the incrementing is done after the operation.
Try this instead:-
i = ++i;


"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Also, check out the following post:
http://www.coderanch.com/t/190825/java-programmer-SCJP/certification/Array


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Thank you.
 
jQuery in Action, 2nd edition
 
subject: ++ operator
 
Similar Threads
need help?
column heading dates ...
how to combine between two arraylist if has same value
Declare an Array?
display error