W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
for (init_stmt; exit_condition; increment_stmt) { code_block }
//The same previous example using For Loop //initializing the custom object records list to store the Invoice Records List<apex_invoice__c> PaidInvoiceNumberList = new List<apex_invoice__c>(); PaidInvoiceNumberList = [SELECT Id,Name, APEX_Status__c FROM APEX_Invoice__c WHERE CreatedDate = today];//this is SOQL query which will fetch the invoice records which has been created today List<string> InvoiceNumberList = new List<string>();//List to store the Invoice Number of Paid invoices for (Integer i = 0; i < paidinvoicenumberlist.size(); i++) { //this loop will iterate on the List PaidInvoiceNumberList and will process the each record. It will get the List Size and will iterate the loop for number of times that size. For example, list size is 10. if (PaidInvoiceNumberList[i].APEX_Status__c == 'Paid') {//Condition to check the current record in context values System.debug('Value of Current Record on which Loop is iterating is '+PaidInvoiceNumberList[i]);//current record on which loop is iterating InvoiceNumberList.add(PaidInvoiceNumberList[i].Name);//if Status value is paid then it will the invoice number into List of String } } System.debug('Value of InvoiceNumberList '+InvoiceNumberList);
//this will print the numbers from 1 to 100} for (Integer i = 0, j = 0; i < 100; i++) { System.debug(i+1) };
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: