This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Increment / decrement > 1 in a for () struct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Increment / decrement > 1 in a for () struct" Watch "Increment / decrement > 1 in a for () struct" New topic
Author

Increment / decrement > 1 in a for () struct

Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401
I have not been able to find information on how (if possible) to 'step' through a for() struct by increments other than one? Is this possible? Without doing math in the signature?
TIA
doco


doco
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Is this possible?
Certainly.
Without doing math in the signature?
Well, without doing anything particularly complex. I mean the standard "i++" is a form of math. You can replace it with other statements though, such as:

or

or

The last in particular is probably a bad idea for readability, since it's not immediately obvious what j and k are, or how many times this loop will execute. But it's legal if you want to do something like that...


"I'm not back." - Bill Harding, Twister
Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401
Now why didn't think of that?
Thanks
doco
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Increment / decrement > 1 in a for () struct