Loops
- The two common loops are the for loop and the while loop.
for (int i = 0; i < 10; i++)
System.out.println(i);
- The for loop has an initializing statement, an end boolean expression,
a terminating statement, and a body.
int i = 0;
while (i < 10) {
System.out.println(i);
i++;
}
- while has an end expression and a body. The two loops above do the same
thing.
- You can also use the do while loop, which always goes through at least
once.