while Loops

Learn how to iterate with a while loop.

Iteration changes the flow of control by repeating a set of statements, zero or more times until a condition is met.

Introduction

In loops, the boolean expression is evaluated before each iteration, including the first iteration. When the expression evaluates to true, the loop body is executed. This continues until the expression evaluates to false, after which the iteration ceases.

Java while loop

The while loop runs a set of instructions as long as a specified condition is true.

Get hands-on with 1200+ tech skills courses.