×
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 do while循环


Apex 循环Apex 循环


Do While循环

与for和while循环测试循环顶部的循环条件不同,do ... while循环在循环底部检查其条件。

一个do ... while循环类似于一个while循环,除了一个do ... while循环被保证至少执行一次。

语法:
do { code_to_execute } while (Boolean_condition);

流程图:
流程图


例如:
对于我们的化学公司,我们将更新列表中唯一的第一个记录,不超过。
//Code for do while loop
List<apex_invoice__c> InvoiceList = [SELECT Id, APEX_Description__c, APEX_Status__c FROM APEX_Invoice__c LIMIT 20];//it will fetch only 20 records 	
Integer i =0;
do {
	InvoiceList[i].APEX_Description__c = 'This is the '+i+' Invoice';
	System.debug('****Updated Description'+InvoiceList[i].APEX_Description__c);//This will print the updated description in debug log
	i++;//Increment the counter
}while (i< 1); 
//iterate till 1st record only


Apex 循环Apex 循环


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)