Skip to main content

목록 FOR 루프 만들기

참고

참고

한국어로 학습하시겠어요? 이 배지에서는 Trailhead 실습과제 검증이 영어로 진행됩니다. 참조용 번역이 괄호로 제공됩니다. 영문으로 표시된 값을 복사하여 붙여 넣은 다음 Trailhead Playground 언어를 영어로, 로캘을 미국으로 전환하세요. 여기 에 나와 있는 지침을 따르세요.

원하는 언어로 Trailhead 사용하기 배지를 확인해 현지화된 Trailhead 경험을 활용하는 방법을 알아보세요.

Trail Together와 함께 알아보기

이 단계를 전문가와 함께 진행하고 싶으신가요? Trail Together 시리즈의 일부인 이 비디오를 시청하세요.

(이 영상은 17분 24초부터 시작합니다. 단계 시작 부분으로 되돌려 다시 시청하려는 경우 참고하세요.)

루프 조정

목록 FOR 루프를 추가하여 전에 만든 bankAccts 목록을 반복합니다. 

  1. Developer Console에서 Execute Anonymous(익명 실행) 창을 엽니다.
  2. 기존 코드를 다음 코드로 바꿉니다.
    //From the BankAcct class, instantiate an object named chkAcct
    BankAcct chkAcct = new BankAcct();
    //Set the accttype attribute of the chkAcct object to Checking
    chkAcct.accttype = 'Checking';
    //Set the acctName attribute of the chkAcct object to D.Castillo-Chk
    chkAcct.acctName = 'D.Castillo-Chk ';
    //Invoke the makeDeposit method with 150 as the argument
    chkAcct.makeDeposit(150);
    //From the BankAcct class, instantiate an object named bankAccts
    BankAcct savAcct = new BankAcct();
    //Set the accttype attribute of the savAcct object to Savings
    savAcct.accttype = 'Savings';
    //Set the acctName attribute of the savAcct object to D.Castillo-Sav
    savAcct.acctName = 'D.Castillo–Sav';
    //Invoke the makeDeposit method with 220 as the argument
    savAcct.makeDeposit(220);
    //From the BankAcct class, instantiate an object named savAcct
    List<BankAcct> bankAccts = new List<BankAcct>();
    System.debug('The BankAcct List has ' + bankAccts.size() + ' bank accounts.');
    //Add the chkAcct object to the bankAccts list
    bankAccts.add(chkAcct);
    //Add the savAcct object to the bankAccts list
    bankAccts.add(savAcct);
    System.debug('The BankAcct List has ' + bankAccts.size() + ' bank accounts.');
    System.debug('Here is the list: ' + bankAccts);
    //Declare a list FOR loop that uses an iteration variable named tempacct
    //to loop through the bankAccts list
    for (BankAcct tempacct:bankAccts){
        system.debug(tempacct.acctName + ' is a ' + tempacct.accttype +
        ' account with a balance of $'+ tempacct.getBalance());
    }
  3. Open Log(로그 열기)가 선택되어 있는지 확인한 후 Execute(실행)를 클릭합니다. 실행 로그가 열립니다.
  4. Debug Only(디버그만)를 선택합니다.
  5. 디버그 메시지를 검토한 후 로그를 닫습니다.

createContact 메서드에서 목록 FOR 루프를 추가하여 Candidate(후보) 목록을 반복합니다.

  1. CreateContactFromCan 클래스에서 기존 코드를 다음 코드로 바꿉니다.
    public with sharing class CreateContactFromCan {
        //Declare a method that returns void and accepts a Candidate list named candsFromTrigger
        public void createContact (List<Candidate__c> candsFromTrigger){
            //Instantiate a Contact list named conList
            List<Contact> conList = new List<Contact>();
            //Declare a list FOR loop that uses an iteration variable named currentCandidate
            //to loop through the candsFromTrigger list
            for(Candidate__c currentCandidate:candsFromTrigger){
            }
        }
    }
  2. CreateContactFromCan 클래스를 저장합니다.
계속해서 무료로 학습하세요!
계속 진행하려면 계정을 가입하세요.
얻을 수 있는 이점
  • 커리어 목표에 대한 개인화된 권장 사항 제공받기
  • 실습 과제 및 퀴즈를 통해 스킬 연습
  • 진행 상황을 추적하고 고용주에게 공유
  • 멘토십과 커리어 기회에 연결