|
Iteration
allows you to repeat a sequence of steps. Java provides three different loops the allow you to implement an iterative algorithm: for loops, while loops, and do while loops.
forThe for loop is typically used as a counting loop. If you want to execute a sequence of steps a fixed number of times (e.g., you know you need to do the same operation 10 times) you should use a for loop. The syntax for a for loop is as follows: |