Skip to content

For

For loop in Java

The for loop in Java is a control structure used to repeatedly execute a block of code a specific number of times. It consists of three parts: initialization, condition, and update. The loop continues to execute as long as the condition is true. The syntax is:

Syntax

for (initialization; condition; update) {
    // code to be executed repeatedly
}

This structure is typically used for iterating over arrays, lists, or ranges of values, making it easy to manage repetitive tasks with a known iteration count.

Short Video Lecture

(Video here)

VisualCodeChat Tutoring (Exercise: Sum of Numbers)

Interact and Learn with VisualCodeChat!

After-class Exercises

(Exercises here)