0Pricing
Java Academy · Lesson

While Loop Basics

Understand while basics: init, condition, update, patterns, and avoiding infinite loops.

Loop Concept

What is a loop? A loop repeats a block while a condition is true. Use it to avoid writing the same line many times.

  • Start with a clear goal
  • Decide what to repeat
  • Stop when the task is done

While Syntax

While syntax

int count = 1;
while (count <= 3) {
System.out.println("Loop " + count);
count = count + 1;
}

Condition is checked before each iteration.

All lessons in this course

  1. While Loop Basics
  2. Do-While & When to Use It
← Back to Java Academy