Course contentsShow
← Computer Science
Lesson 183 of 2,8724. Introduction to ProgrammingFree lesson

The Continue Statement

Skipping the current iteration and moving to the next one using the continue statement.

The Continue Statement

What you'll learn: How to skip the rest of the current loop iteration and jump directly to the next one.

What Does Continue Do?

The continue statement is a control tool that lets you skip the remaining code in the current iteration of a loop and immediately move to the next iteration. Think of it like a "fast-forward" button—when you hit continue, the loop doesn't stop entirely (that's what break does), but it skips ahead to check the condition and start the next cycle.

How It Works

When a loop encounters a continue statement:

  1. It immediately stops executing any remaining code in that iteration
  2. For a while loop, it jumps back to check the loop condition
  3. For a for loop, it jumps to the update step, then checks the condition
  4. The loop then proceeds with the next iteration (if the condition is still true)

When to Use Continue

Use continue when you want to skip processing certain items without exiting the loop entirely. For example, if you're processing a list of numbers but want to skip negative values, continue lets you bypass them cleanly.

Analogy

Imagine reading a book chapter by chapter. Using break is like closing the book entirely. Using continue is like skipping the current chapter and jumping straight to the next one—you keep reading, just not this part.

Key Takeaway: The continue statement skips the rest of the current loop iteration and moves immediately to the next one, allowing selective processing without terminating the entire loop.