Apex Developer Guide
Release Notes
Conditional (If-Else) Statements
Switch Statements
Apex Reference
Previous PDF Versions
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
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
The conditional statement in Apex works similarly to Java.
Apex provides a switch statement that tests whether an expression matches one of several values and branches accordingly.
Apex supports five types of procedural loops.