Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loops

 
Nath Maniedeo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic