permaculture playing cards*
The moose likes Cattle Drive and the fly likes Loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Loops" Watch "Loops" New topic
Author

Loops

Nath Maniedeo
Greenhorn

Joined: Feb 15, 2008
Posts: 29
hi - I'm new. our teacher wrote: "While this kind of for loop does work, it is not as readable as a more traditional loop.
If I use a for loop, I like to see all three sections used."

so, what's a more traditional loop - the while loop? (I thought this was not ideal)

what are the 3 sections of the for loop?
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1358
    
  17
Hi there,

The traditional for loop takes 3 sections:

initializor
loop test
a counting expression (often an incrementor)

this usually looks like this:
Nath Maniedeo
Greenhorn

Joined: Feb 15, 2008
Posts: 29
thank you!
 
 
subject: Loops