Skip to main content
The Trailblazer Community will undergo maintenance on Saturday, November 15, 2025 and Sunday, November 16, 2025. Please plan your activities accordingly.

创建列表

备注

备注

用中文(简体)学习?在中文(简体)Trailhead Playground 中开始挑战,用括号中提供的译文完成挑战。仅复制并粘贴英文值,因为挑战验证基于英文数据。如果在中文(简体)组织中没有成功通过挑战,我们建议您 (1) 将区域设置切换为美国,(2) 按此处说明将语言切换为英文,(3) 再次单击“检查挑战”按钮。

查看 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 类。
在 Salesforce 帮助中分享 Trailhead 反馈

我们很想听听您使用 Trailhead 的经验——您现在可以随时从 Salesforce 帮助网站访问新的反馈表单。

了解更多 继续分享反馈