课程表

Apex课程

工具箱
速查手册

Apex - do while循环

当前位置:免费教程 » 程序设计 » Apex
与for和while循环测试循环顶部的循环条件不同,do ... while循环在循环底部检查其条件。

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

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

流程图:
流程图


例如:
对于我们的化学公司,我们将更新列表中唯一的第一个记录,不超过。
  1. //Code for do while loop
  2. 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
  3. Integer i =0;
  4. do {
  5. InvoiceList[i].APEX_Description__c = 'This is the '+i+' Invoice';
  6. System.debug('****Updated Description'+InvoiceList[i].APEX_Description__c);//This will print the updated description in debug log
  7. i++;//Increment the counter
  8. }while (i< 1);
  9. //iterate till 1st record only

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号