for (int i = 0; i < 10; i++)
System.out.println(i);
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.