---
schema_version: "1"
id: ea641d8be46753115151fbf9b8c3886f30dc341854ee9c04cd0cbfe688b11a9a
title: Control Flow Statements
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_control_flow.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_control_flow.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1db23bcd7053139bff75a3cb575602b28e72190d835032b8fdf4c976c5832053
description: Apex provides if-else statements, switch statements, and loops to control the flow of code execution. Statements are generally executed line by line, in the order they appear. With control flow statements, you can make Apex code execute based on a certain condition, or have a block of code execute repeatedly.
---
# Control Flow Statements

Apex provides if-else statements, switch statements, and loops to control the flow of code execution. Statements are generally executed line by line, in the order they appear. With control flow statements, you can make Apex code execute based on a certain condition, or have a block of code execute repeatedly.

- **[Conditional (If-Else) Statements](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_if_else.htm)**  
    The conditional statement in Apex works similarly to Java.
- **[Switch Statements](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_switch.htm)**  
    Apex provides a switch statement that tests whether an expression matches one of several values and branches accordingly.
- **[Loops](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops.htm)**  
    Apex supports five types of procedural loops.