Java: Do while loop

This entry is part 15 of 54 in the series Learn Java

The do-while loop works the same way as the while loop, except that it checks the condition after the code block.

It will therefore always run through the code block at least once.

package javaapplication14;

public class JavaApplication14 {

    public static void main(String[] args) {
        int i = 0;
        do {
            System.out.print(" ");
        } while (i < 10);


Series Navigation<< Java: Ternary operator (?:)
Java: Calling methods >>

Leave a comment

Leave a Reply