Skip to main content

创建列表

备注

备注

用中文(简体)学习?在此徽章中,Trailhead 实践挑战验证使用英文。括号中提供了译文,用作参考。确保复制粘贴英文值,将 Trailhead Playground 切换为英语,将区域设置切换为美国。按此处说明进行。

查看 Trailhead 本地化语言徽章了解如何利用 Trailhead 译文。

跟随 Trail Together 进行学习

进行这一步骤时,想要跟专家一起学习吗?观看此视频,它是 Trail Together 系列的一部分。

(这部分内容从 13:30 开始,如果您想要倒回去再次观看步骤的开头部分可以从这里开始。)

创建并调整列表

将名为 bankAccts 的列表实例化并且给该列表增加两个 BankAcct 对象。

  1. 打开 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 savAcct
    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 List class, instantiate a BankAcct List object named bankAccts
    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);
  3. 确认 Open Log(打开日志)被选中,然后单击 Execute(执行)。执行日志打开。
  4. 选中 Debug Only(仅限调试)
  5. 查看调试消息,然后关闭日志。

在 createContact 方法中,把一个 Contact List(联系人列表)对象实例化,接受一个称作 candsFromTrigger 的 Candidate List(候选人列表)对象作为参数。 

  1. 在 Developer Console 中,打开 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>();
        }
    }
  2. 保存 CreateContactFromCan 类。
继续免费学习!
注册帐户以继续。
有什么适合您的内容?
  • 为您的职业目标获取个性化推荐
  • 通过实践挑战和测验练习您的技能
  • 跟踪并与雇主分享您的进度
  • 与人联系以获取指导和就业机会