Introduction to the for Loop

Learn to simplify for loop and leverage iterable for powerful iteration.

Traditional for loop structure

In Java and other older languages, a for loop typically has three parts:

  1. The first part initializes the variable before the loop starts.

  2. The second part contains the condition for the execution of the code block.

  3. The third part is executed after the code block.

Get hands-on with 1200+ tech skills courses.