Fundamentals4 / 25
Up next

for loop

class Main {
    public static void main(String[] args) {
        int total = 0;
        // init; condition; step
        for (int i = 1; i < 5; i++) {
            total += i;
        }
        System.out.println(total);
    }
}
What you're solving

the classic index-driven loop