aspose file tools*
The moose likes Beginning Java and the fly likes working of increment operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "working of increment operator" Watch "working of increment operator" New topic

working of increment operator

D Preethi
Ranch Hand

Joined: May 24, 2008
Posts: 68
Hi All,

I just saw 2 questions on the working of increment operator and, couldn't understand the output for them. Can someone please explain?

Ques 1.

output: 13:0

Ques 2:

output: 14:0

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 39409
Java arithmetic works from left to right. The [] has a high precedence, rather like (), so the i++ in the [] is evaluated first, then the i++ after the = then the 3ed i++.

Remember that i++ increments the value of i, but the whole expression returns the old value of i.

Now you should be able to work it out for yourself.
jQuery in Action, 2nd edition
subject: working of increment operator