×
Apex 编程教程Apex 环境Apex 示例Apex 数据类型Apex 变量Apex 字符串Apex 数组Apex 常量Apex 决策Apex 循环Apex 集合Apex 类Apex 类方法Apex 对象Apex 接口Apex DMLApex 数据库方法Apex SOSLApex SOQLApex 安全性Apex 调用Apex 触发器Apex 触发设计模式Governer Limits调节器限制Apex 批量处理Apex 调试Apex 测试Apex 部署Apex 字符串Apex 数组

Apex 嵌套if语句


Apex 决策Apex 决策


嵌套if-else

我们也可以有复杂条件的嵌套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 = '12345';
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 决策Apex 决策


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)