This page contains an overview of the three different loops in Java.

  1. For-Loops allow running through the loop in the case you know the start- and endpoint in advance.
  2. While-Loops are more flexible. While-Loops do not necessarily need an adjusted endpoint. Like the example 2 shows, the endpoint could be after infinity many trails or already after 2 trails.
  3. Do-While-Loops are like While-Loops (Like we have seen in the chapter about Do-While-Loops.), the difference is that the While-Loop first checks if the statement is true and if it is still true executes the code. The Do-While-Loop first executes the code ones and after that, it checks if the statement(s) is/are still true and if the loop has to continue or has to stop when the statement(s) is/are not true anymore (in other words, if the statement is false).