- Apex 编程教程
- Apex - 主页
- Apex - 概览
- Apex - 环境
- Apex - 示例
- Apex - 数据类型
- Apex - 变量
- Apex - 字符串
- Apex - 数组
- Apex - 常量
- Apex - 决策制定
- Apex - 循环
- Apex - 集合
- Apex - 类
- Apex - 方法
- Apex - 对象
- Apex - 接口
- Apex - DML
- Apex - 数据库方法
- Apex - SOSL
- Apex - SOQL
- Apex - 安全
- Apex - 调用
- Apex - 触发器
- Apex - 触发器设计模式
- Apex - 管理员限制
- Apex - 批处理
- Apex - 调试
- Apex - 测试
- Apex - 部署
- 有用的 Apex 资源
- Apex - 快速指南
- Apex - 资源
- Apex - 讨论
Apex - 嵌套 if 语句
对于复杂的条件,我们还可以使用嵌套if-else语句,如下所示 −
语法
if boolean_expression_1 {
/* Executes when the boolean expression 1 is true */
if boolean_expression_2 {
/* Executes when the boolean expression 2 is true */
}
}
示例
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
广告