Lesson

Codecademy Learn Java, For Loop, Data Structures

Lesson Summary

In this Java lesson we go over the for loop. The for loop allows us to continue executing code as long as a condition is met. The for loop takes an initial value and then a condition, then what will happen if the condition is true(this is where the code you want to execute goes). In the example we are shown the initial value of waterLevel being 0. Then we say as long as 0 is less than 7 we will increase or increment waterLevel by one. As long as that condition is true we keep increasing waterLevel by 1. As long as that condition is true the code within the curly braces will execute.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required


Share: