
- Apex Programming Tutorial
- Apex - Home
- Apex - Overview
- Apex - Environment
- Apex - Example
- Apex - Data Types
- Apex - Variables
- Apex - Strings
- Apex - Arrays
- Apex - Constants
- Apex - Decision Making
- Apex - Loops
- Apex - Collections
- Apex - Classes
- Apex - Methods
- Apex - Objects
- Apex - Interfaces
- Apex - DML
- Apex - Database Methods
- Apex - SOSL
- Apex - SOQL
- Apex - Security
- Apex - Invoking
- Apex - Triggers
- Apex - Trigger Design Patterns
- Apex - Governer Limits
- Apex - Batch Processing
- Apex - Debugging
- Apex - Testing
- Apex - Deployment
- Apex Useful Resources
- Apex - Quick Guide
- Apex - Resources
- Apex - Discussion
Apex - nested if statement
We can also have the nested if-else statement for complex condition as given below −
Syntax
if boolean_expression_1 { /* Executes when the boolean expression 1 is true */ if boolean_expression_2 { /* Executes when the boolean expression 2 is true */ } }
Example
String pinCode = '12345'; String customerType = 'Premium'; if (pinCode == '12345') { System.debug('Condition met and Pin Code is'+pinCode); if(customerType = 'Premium') { System.debug('This is a Premium customer living in pinCode 12345'); }else if(customerType = 'Normal') { System.debug('This is a Normal customer living in pinCode 12345'); } }else { //this can go on as per the requirement System.debug('Pincode not found'); }
apex_decision_making.htm
Advertisements